我在超级方法参数中添加了子类和self,仍然 错误仍然存在。您可以提出任何建议吗?此外,我尝试在python 2和python 3上都运行代码,但是仍然存在相同的问题。
TypeError Traceback (most recent call last)
<ipython-input-66-4a9264e84ddd> in <module>()
49 model = Sequential()
50 model.add(LSTM(150, input_shape=(n_timesteps_in, n_features),
return_sequences=True))
---> 51 model.add(AttentionDecoder(127, n_features))
52 model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=
['acc'])
53 # train LSTM
51
52 super(AttentionDecoder, self). __init__(units, output_dim)
---> 53 self.name = name
54 self.return_sequences = True # must return sequences
55
TypeError: super() takes at least 1 argument (0 given)
class AttentionDecoder(Recurrent):
def __init__(self, units, output_dim,
activation='tanh',
return_probabilities=False,
name='AttentionDecoder',
kernel_initializer='glorot_uniform',
recurrent_initializer='orthogonal',
bias_initializer='zeros',
kernel_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
kernel_constraint=None,
bias_constraint=None,
**kwargs):
super(AttentionDecoder, self). __init__(units, output_dim)
self.name = name
self.return_sequences = True # must return sequences