【发布时间】:2020-04-30 07:38:48
【问题描述】:
word_embed = keras.layers.Embedding(len(vocab), 101)
em = word_embed(tf.convert_to_tensor(np.random.rand(10, 48)))
print(em.shape)
# (10, 48, 101)
# 10 sentences in bacth, 48 words in sentence(with padding), 101 - embedding dimension...
lstm = K.layers.LSTMCell(101)
lstm_layer = keras.layers.RNN(lstm)hidden_states = lstm_layer(em)
# TypeError: Expected Operation, Variable, or Tensor, got False
谁能帮忙,为什么会出现错误?预期 lstm 单元的隐藏状态...
【问题讨论】:
-
你想在这里做什么?为什么要将
lstm层传递给RNN层,为什么要使用LSTMCell而不是LSTM?
标签: python keras tensorflow2.0