亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

列車功能內部和外部的結果不同

列車功能內部和外部的結果不同

蝴蝶不菲 2022-08-02 17:31:51
我正在玩張量流2。我做了我自己的模型,類似于這里的做法。然后我創建了自己的擬合函數。現在我得到了有史以來最奇怪的事情。以下是我進行測試的筆記本的精確復制/粘貼輸出:def fit(x_train, y_train, learning_rate=0.01, epochs=10, batch_size=100, normal=True, verbose=True, display_freq=100):    if normal:        x_train = normalize(x_train)  # TODO: This normalize could be a bit different for each and be bad.    num_tr_iter = int(len(y_train) / batch_size)  # Number of training iterations in each epoch    if verbose:        print("Starting training...")    for epoch in range(epochs):        # Randomly shuffle the training data at the beginning of each epoch        x_train, y_train = randomize(x_train, y_train)        for iteration in range(num_tr_iter):            # Get the batch            start = iteration * batch_size            end = (iteration + 1) * batch_size            x_batch, y_batch = get_next_batch(x_train, y_train, start, end)            # Run optimization op (backpropagation)            # import pdb; pdb.set_trace()            if verbose and (epoch * batch_size + iteration) % display_freq == 0:                current_loss = _apply_loss(y_train, model(x_train, training=True))                current_acc = evaluate_accuracy(x_train, y_train)                print("Epoch: {0}/{1}; batch {2}/{3}; loss: {4:.4f}; accuracy: {5:.2f} %"                      .format(epoch, epochs, iteration, num_tr_iter, current_loss, current_acc*100))            train_step(x_batch, y_batch, learning_rate)    current_loss = _apply_loss(y_train, model(x_train, training=True))    current_acc = evaluate_accuracy(x_train, y_train)    print("End: loss: {0:.4f}; accuracy: {1:.2f} %".format(current_loss, current_acc*100))import logginglogging.getLogger('tensorflow').disabled = Truefit(x_train, y_train)current_loss = _apply_loss(y_train, model(x_train, training=True))current_acc = evaluate_accuracy(x_train, y_train)print("End: loss: {0:.4f}; accuracy: {1:.2f} %".format(current_loss, current_acc*100))現在我的問題是,我如何在最后2行上得到不同的值???我在做同樣的事情對吧?我在這里完全困惑。我甚至不知道如何谷歌這個。
查看完整描述

1 回答

?
慕桂英4014372

TA貢獻1871條經驗 獲得超13個贊

所以問題只是愚蠢的。這是由于我在火車示例開始時所做的規范化操作!已將其刪除并開始工作 正常。


查看完整回答
反對 回復 2022-08-02
  • 1 回答
  • 0 關注
  • 103 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號