第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

從官方 tensorflow 頁(yè)面了解代碼

從官方 tensorflow 頁(yè)面了解代碼

慕蓋茨4494581 2022-07-05 17:07:36
我對(duì)此頁(yè)面上的代碼感到困惑。問(wèn)題1)下面的代碼塊顯示了該頁(yè)面的輸出。在這一步之前,我沒有看到任何使用model.fit函數(shù)訓(xùn)練我們的數(shù)據(jù)的代碼。那么下面的代碼是什么?他們是否使用隨機(jī)權(quán)重顯示預(yù)測(cè)?model.predict(train_features[:10])array([[0.6296253 ],       [0.82509124],       [0.75135857],       [0.73724824],       [0.82174015],       [0.33519754],       [0.6719973 ],       [0.30910844],       [0.6378555 ],       [0.8381703 ]], dtype=float32)model = make_model(output_bias = initial_bias)model.predict(train_features[:10])array([[0.00124893],       [0.00185736],       [0.00164955],       [0.00123761],       [0.00137692],       [0.00182851],       [0.00170887],       [0.00239349],       [0.0024704 ],       [0.00517672]], dtype=float32)results = model.evaluate(train_features, train_labels, batch_size=BATCH_SIZE, verbose=0)print("Loss: {:0.4f}".format(results[0]))Loss: 0.0157問(wèn)題2)繼續(xù)在下面說(shuō)的代碼中。是什么initial_weights?它們是隨機(jī)值嗎?initial_weights = os.path.join(tempfile.mkdtemp(),'initial_weights')model.save_weights(initial_weights)問(wèn)題3)然后他們說(shuō)Before moving on, confirm quick that the careful bias initialization actually helped.Train the model for 20 epochs, with and without this careful initialization, and compare the losses:, 但我不確定他們是如何分配初始偏差的。我知道我們?yōu)閷?duì)象分配了 0 偏差zero_bias_history。但是我們?nèi)绾畏峙淦奵areful_bias_history呢?它不應(yīng)該具有等于initial_bias. 如何careful_bias_history獲得偏差值?我覺得careful_bias_history應(yīng)該從使用創(chuàng)建的模型創(chuàng)建model = make_model(output_bias = initial_bias)### Confirm that the bias fix helpsBefore moving on, confirm quick that the careful bias initialization actually helped.Train the model for 20 epochs, with and without this careful initialization, and compare the losses: model = make_model()model.load_weights(initial_weights)model.layers[-1].bias.assign([0.0])zero_bias_history = model.fit(    train_features,    train_labels,    batch_size=BATCH_SIZE,    epochs=20,    validation_data=(val_features, val_labels),     verbose=0)print (type(model))#model.load_weights()
查看完整描述

1 回答

?
慕村9548890

TA貢獻(xiàn)1884條經(jīng)驗(yàn) 獲得超4個(gè)贊

答案 1:是的,這些預(yù)測(cè)來(lái)自模型編譯后但在訓(xùn)練之前。

答案 2:是的,它們是隨機(jī)權(quán)重,例如,在 Dense 層中,它們使用glorot_uniformtf.keras.layers.Dense

答案 3:我們上面保存的模型有一個(gè)使用 初始化的偏差np.log([pos/neg]),這里提到。

因此,在 中zero_bias_history,他們使用 將偏差初始化為零model.layers[-1].bias.assign([0.0]),并在careful_bias_history其中加載了已經(jīng)具有初始化偏差的已保存模型。


查看完整回答
反對(duì) 回復(fù) 2022-07-05
  • 1 回答
  • 0 關(guān)注
  • 173 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)