2016-11-16 42 views
1

我正在做一個關於圖像字幕的項目。我想用shape =(batch_size,512)設置一批圖像特徵作爲Lasagne(theano)中LSTMLayer的初始隱藏狀態。輸入到LSTMLayer的序列是一批具有shape =(batch_size,max_sequence_length,512)的文本序列。我注意到lasagne中的LSTMLayer有一個hid_init參數。有誰知道如何將它用於Lasagne的LSTMLayer?我是否需要自己實施自定義LSTMLayer?千層麪使用圖像輸入作爲LSTMLayer的初始隱藏狀態

回答

1

你不需要設置H_0參數,因爲H_0使用C0(見本enter link description here並記下從H0到C0連接),所以,你必須設置只C0參數:

decoder = LSTMLayer(l_word_embeddings, 
       num_units=LSTM_UNITS, 
       cell_init=your_image_features_layer_512_shape, #this is c0 
       mask_input=l_mask) 

可以設置c0作爲層或作爲其他陣列(參見lasagne LSTM doc enter link description here)。

準備好進一步討論。