【发布时间】:2020-10-24 09:10:55
【问题描述】:
1270个时间步长,每个时间步长为36; 10节课
max_length = 1270
step_dim = 36
_input = Input(shape=[max_length, step_dim])
activations = LSTM(128, return_sequences=True)(_input)
# compute importance for each step
attention = Dense(1, activation='tanh')(activations)
attention = Flatten()(attention)
attention = Activation('softmax')(attention)
attention = RepeatVector(1270)(attention)
attention = Permute([2, 1])(attention)
sent_representation = merge([activations, attention], mode='mul')
sent_representation = Lambda(lambda xin: K.sum(xin, axis=-2), output_shape=(64,))(sent_representation)
probabilities = Dense(10, activation='softmax')(sent_representation)
给予:
TypeError: 'module' 对象不可调用
这是什么意思,我该如何解决?
【问题讨论】:
-
这是什么合并()。从您导入它的地方。请提供完整的脚本以及您在哪一行得到错误
-
@devSpartan merge() 是一个标准的 Keras 层。错误是指 merge() 行。
-
对不起老兄,我没有找到名为merge的keras层。还有其他合并层,例如添加、连接、点、最小值等
-
@devSpartan 是的,现在使用乘法层。并将 RepeatVector() 的输入更改为 128。现在,它可以工作了。
标签: python keras deep-learning lstm attention-model