0
Q
LSTM條件
A
回答
1
繼承人申請CNN和LSTM一個序列的輸出概率,像你這樣的例子問:
def build_model(inputs):
BATCH_SIZE = 4
NUM_CLASSES = 2
NUM_UNITS = 128
H = 224
W = 224
C = 3
TIME_STEPS = 4
# inputs is assumed to be of shape (BATCH_SIZE, TIME_STEPS, H, W, C)
# reshape your input such that you can apply the CNN for all images
input_cnn_reshaped = tf.reshape(inputs, (-1, H, W, C))
# define CNN, for instance vgg 16
cnn_logits_output, _ = vgg_16(input_cnn_reshaped, num_classes=NUM_CLASSES)
cnn_probabilities_output = tf.nn.softmax(cnn_logits_output)
# reshape back to time series convention
cnn_probabilities_output = tf.reshape(cnn_probabilities_output, (BATCH_SIZE, TIME_STEPS, NUM_CLASSES))
# perform LSTM over the probabilities per image
cell = tf.contrib.rnn.LSTMCell(NUM_UNITS)
_, state = tf.nn.dynamic_rnn(cell, cnn_probabilities_output)
# employ FC layer over the last state
logits = tf.layers.dense(state, NUM_UNITS)
# logits is of shape (BATCH_SIZE, NUM_CLASSES)
return logits
順便說一句,一個更好的辦法是聘請LSTM過去隱藏層,即使用CNN作爲特徵提取器並對特徵序列進行預測。
+0
非常感謝!這是我真正想要的。我打算更多地研究LSTM和TF的用法來實現上述概念。謝謝 –
相關問題
- 1. 與LSTM在烤寬麪條
- 2. Multidimentional lstm tensorflow
- 3. keras狀態LSTM
- 4. Deeplearning4j LSTM示例
- 5. LSTM在CNN
- 6. 爲keras LSTM
- 7. LSTM with keras
- 8. 一對一LSTM
- 9. LSTM訓練模式
- 10. TimeDistributed LSTM的問題
- 11. Caffe的LSTM模塊
- 12. Stateful LSTM的實現
- 13. LSTM錯誤蟒蛇
- 14. Keras LSTM不訓練
- 15. 如何使用LSTM
- 16. 可視化RNN/LSTM
- 17. LSTM/RNN多對一
- 18. Tensorflow LSTM - 在LSTM單元上的矩陣乘法
- 19. CNTK提供最終LSTM狀態輸入到另一個LSTM
- 20. tf.contrib.rnn.BasicLSTMCell是單個LSTM單元還是LSTM層?
- 21. Keras:從Keras文檔LSTM漏失和LSTM複發性差
- 22. TensorFlow:記住下一批次的LSTM狀態(有狀態的LSTM)
- 23. 整形Keras輸入爲LSTM
- 24. LSTM時間序列分類
- 25. Keras中的一對多LSTM
- 26. Keras LSTM Shape for Pandas DataFrame
- 27. Keras重塑輸入LSTM
- 28. Keras中的LSTM輸入
- 29. T-FLearn中的多層LSTM
- 30. Keras LSTM:第一個參數
您能否詳細說明「將一些標量標籤放入LSTM網絡作爲條件」是什麼意思? – amirbar
@amirbar這意味着網絡被構建成2個部分 - 分類和LSTM。因此將分類結果放入LSTM網絡作爲提高LSTM性能的條件。 –
只是爲了確保我理解這個問題 - 所以你想要一個使用LSTM和CNN的時間序列預測圖像的例子嗎?您是否試圖在時間序列中預測每個圖像系列圖像或標籤的單個標籤? – amirbar