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

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

是否可以逐部分訓(xùn)練深度神經(jīng)網(wǎng)絡(luò)的輸入

是否可以逐部分訓(xùn)練深度神經(jīng)網(wǎng)絡(luò)的輸入

手掌心 2022-06-14 15:37:27
我想知道是否可以部分訓(xùn)練神經(jīng)網(wǎng)絡(luò)的輸入。例如,假設(shè)我有輸入 256 和輸出 256 的神經(jīng)網(wǎng)絡(luò)。我要問的是是否有可能采取組,其中每個組僅包含 265 個輸入中的 16 個,以便基于單個輸入進(jìn)行預(yù)測模型獨(dú)立訓(xùn)練,然后在最終輸出中連接整個組。例如,提供了以下示例:from matplotlib import pyplot as pltimport tensorflow as tftf.reset_default_graph()x_train = [[0.,0.],[1.,1.],[1.,0.],[0.,1.]]y_train = [[0.],[0.],[1.],[1.]]x_test =  [[0.,0.],[.5,.5],[.5,0.],[0.,.5]]y_test = [[0.],[0.],[2.],[2.]]# use placeholder instead so you can have different inputsx = tf.placeholder('float32', [None, 2])y = tf.placeholder('float32',)# Layer 1 = the 2x3 hidden sigmoidm1 = tf.Variable(tf.random_uniform([2,3], minval=0.1, maxval=0.9, dtype=tf.float32))b1 = tf.Variable(tf.random_uniform([3], minval=0.1, maxval=0.9, dtype=tf.float32))h1 = tf.sigmoid(tf.matmul(x, m1) + b1)# Layer 2 = the 3x1 sigmoid outputm2 = tf.Variable(tf.random_uniform([3,1], minval=0.1, maxval=0.9, dtype=tf.float32))b2 = tf.Variable(tf.random_uniform([1], minval=0.1, maxval=0.9, dtype=tf.float32))y_out = tf.sigmoid(tf.matmul(h1, m2) + b2)### loss# loss : sum of the squares of y0 - y_outloss = tf.reduce_sum(tf.square(y - y_out))# training step : gradient decent (1.0) to minimize losstrain = tf.train.GradientDescentOptimizer(1.0).minimize(loss)# the two feed dictionariesfeeddict_train = {x: x_train, y: y_train}feeddict_test = {x: x_test, y: y_test}### training# run 500 times using all the X and Y# print out the loss and any other interesting infowith tf.Session() as sess:    sess.run(tf.global_variables_initializer())    train_loss, test_loss = [], []    for step in range(500):        loss_train, _ = sess.run([loss, train], feed_dict=feeddict_train)        train_loss.append(loss_train)        # under the same tensorflow graph (in the session), use another feed dictionary         loss_test = sess.run(loss, feed_dict=feeddict_test)        test_loss.append(loss_test)在此命令中,將獲取和訓(xùn)練loss_test = sess.run(loss, feed_dict=feeddict_test)整個輸入。feeddict_test如果我想把它分成兩組,每個組只包含可用的 4 個項目中的 2 個,然后單獨(dú)測試它們并連接輸出,這可能嗎?我怎樣才能做到這一點(diǎn)?如果可能的話,你能幫我這樣做嗎?
查看完整描述

1 回答

?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗 獲得超8個贊

由于您的問題不準(zhǔn)確,您的問題幾乎無法解釋。


第一種解釋: 如果您要問的是,如果您的神經(jīng)網(wǎng)絡(luò)接收大小為 256 的輸入向量并輸出大小為 256的向量,那么答案是否定的,您不能輸入向量的一部分作為輸入并期望它工作。


第二種解釋: 如果您要問的是,如果您有 256個數(shù)據(jù)(每個數(shù)據(jù)是一個 n 大小的向量)并且您想通過輸入前 16 個,然后是第二個 16,以此類推直到第 16 個來訓(xùn)練網(wǎng)絡(luò)16,是的,很有可能。根據(jù)您給出的示例代碼,您需要做的就是創(chuàng)建一個循環(huán) 2 次的 for 循環(huán)(因為在您的示例中,有 4 個數(shù)據(jù),您希望將它們輸入一組 2)并且,


更改這些代碼行:


for step in range(500):

        loss_train, _ = sess.run([loss, train], feed_dict=feeddict_train)`


for step in range(500):

        temp_list = [] #an empty list

        for i in range(0,4,2):

               loss_train, _ = sess.run([loss, train], feed_dict={x:x_train[i:i+2], y:y_train[i:i+2]}

               temp_list.append(loss_train) #append the loss of the network for each group of data.

這些將允許網(wǎng)絡(luò)獨(dú)立地使用兩組數(shù)據(jù)進(jìn)行訓(xùn)練并從中學(xué)習(xí)。您可以在新的 for 循環(huán)之前簡單地創(chuàng)建一個空列表并將其中的輸出連接起來。


希望這可以幫助。如果我錯誤地理解了您的問題,請告訴我。干杯。


查看完整回答
反對 回復(fù) 2022-06-14
  • 1 回答
  • 0 關(guān)注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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