【发布时间】:2019-03-04 03:31:45
【问题描述】:
我得到了这个示例代码,但不知道如何计算可训练参数为 335872? (显示在以下输出中)
如果有人可以帮助解决这个问题,我将不胜感激。谢谢!
--------------代码---------- ---------------
input_shape = (None, num_encoder_tokens)
# Define an input sequence and process it.
encoder_inputs = Input(shape=input_shape)
encoder = LSTM(latent_dim, return_state=True)
encoder_outputs, state_h, state_c = encoder(encoder_inputs)
# We discard `encoder_outputs` and only keep the states.
encoder_states = [state_h, state_c]
encoder_model = Model(encoder_inputs, encoder_states)
encoder_model.summary(line_length=100)
encoder_model.output_shape
----------输出如下----------
Layer (type) Output Shape Param #
=================================================================================
input_2 (InputLayer) (None, None, 71) 0
_________________________________________________________________________________
lstm_5 (LSTM) [(None, 256), (None, 256), (None, 256)] 335872
=================================================================================
Total params: 335,872
Trainable params: 335,872
Non-trainable params: 0
_________________________________________________________________________________
[(None, 256), (None, 256)]
【问题讨论】:
-
你能说出
latent_dim和num_encoder_tokens的值吗?
标签: python machine-learning keras lstm