要求澄清keras model.predict输出

时间:2018-04-04 15:19:44

标签: python keras lstm

我有一个输入大小为8且输出大小为2的模型。但是当我仅使用一个数据使用model.predict时,它会打印一个(8,2)形状的2d数组。谁能解释一下model.predict输出究竟是什么?

输出:

[[ 0.09589279  0.08555986]
 [ 0.09596384  0.08550422]
 [ 0.09589279  0.08555986]
 [ 0.09537797  0.08605254]
 [ 0.09537797  0.08605254]
 [ 0.09537797  0.08605254]
 [ 0.09537797  0.08605254]
 [ 0.09537797  0.08605254]]

要点:

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
embedding_1 (Embedding)      (None, None, 2)           16        
_________________________________________________________________
lstm_1 (LSTM)                (None, None, 256)         265216    
_________________________________________________________________
dropout_1 (Dropout)          (None, None, 256)         0         
_________________________________________________________________
lstm_2 (LSTM)                (None, None, 256)         525312    
_________________________________________________________________
dropout_2 (Dropout)          (None, None, 256)         0         
_________________________________________________________________
lstm_3 (LSTM)                (None, None, 256)         525312    
_________________________________________________________________
dropout_3 (Dropout)          (None, None, 256)         0         
_________________________________________________________________
lstm_4 (LSTM)                (None, None, 256)         525312    
_________________________________________________________________
dropout_4 (Dropout)          (None, None, 256)         0         
_________________________________________________________________
lstm_5 (LSTM)                (None, 256)               525312    
_________________________________________________________________
dropout_5 (Dropout)          (None, 256)               0         
_________________________________________________________________
dense_1 (Dense)              (None, 2)                 514       
_________________________________________________________________
activation_1 (Activation)    (None, 2)                 0         
=================================================================
Total params: 2,366,994
Trainable params: 2,366,994
Non-trainable params: 0
_________________________________________________________________
None

1 个答案:

答案 0 :(得分:0)

嗯,您的输入数据肯定有(number_of_sequences, timeSteps)形状。

总结显示输出为(number_of_sequences, 2)是完全正常的。

这意味着输入数据中有8个序列。每个序列都有一些时间步,我无法从这个摘要中知道(None表示变量)。这些时间步长将一直存在,直到最后一个使用return_sequences=False的LSTM层。

在摘要中:

  • 第一个None =序列数
  • 第二个None =时间步数