我尝试使用Keras构建一个三层的RNN模型。以下是其中一部分代码:
model = Sequential()
model.add(Embedding(input_dim = 91, output_dim = 128, input_length =max_length))
model.add(GRUCell(units = self.neurons, dropout = self.dropval, bias_initializer = bias))
model.add(GRUCell(units = self.neurons, dropout = self.dropval, bias_initializer = bias))
model.add(GRUCell(units = self.neurons, dropout = self.dropval, bias_initializer = bias))
model.add(TimeDistributed(Dense(target.shape[2])))
然后我遇到了这个错误:
call() missing 1 required positional argument: 'states'
错误详情如下:
~/anaconda3/envs/hw3/lib/python3.5/site-packages/keras/models.py in add(self, layer)
487 output_shapes=[self.outputs[0]._keras_shape])
488 else:
--> 489 output_tensor = layer(self.outputs[0])
490 if isinstance(output_tensor, list):
491 raise TypeError('All layers in a Sequential model '
~/anaconda3/envs/hw3/lib/python3.5/site-packages/keras/engine/topology.py in __call__(self, inputs, **kwargs)
601
602 # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 603 output = self.call(inputs, **kwargs)
604 output_mask = self.compute_mask(inputs, previous_mask)
605