我尝试预测网格图中的2D坐标序列。要做到这一点,我有一个Input_train
形状(41185, 10, 2)
的训练集,所以我有41185个序列的例子,它们是10个步长,每个步骤加上2个坐标。
这是我的模特:
self.model = Sequential()
self.model.add(LSTM(self.num_neurons, input_shape=(10, 2), dropout=self.dropout, recurrent_dropout=self.dropout,
return_sequences=True))
for _ in range(self.depth - 1):
self.model.add(
LSTM(self.num_neurons, dropout=self.dropout, recurrent_dropout=self.dropout,
return_sequences=True))
self.model.add(
LSTM(self.num_neurons, dropout=self.dropout, recurrent_dropout=self.dropout))
self.model.add(Dense(units=3802, activation='relu'))
self.model.compile(loss=self._get_loss(), optimizer=self._build_optimizer())
我的网络输出应为3802 x 3802阵列,未来坐标在相应的条目中标记为1。
电话:
model.summary()
print "Inputs: {}".format(model.input_shape)
print "Outputs: {}".format(model.output_shape)
print "Actual input: {}".format(Input_train.shape)
print "Actual output: {}".format(Labels_train[0].shape)
产率:
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
lstm_1 (LSTM) (None, None, 258) 269352
_________________________________________________________________
lstm_2 (LSTM) (None, None, 258) 533544
_________________________________________________________________
lstm_3 (LSTM) (None, 258) 533544
_________________________________________________________________
dense_1 (Dense) (None, 3802) 984718
=================================================================
Total params: 2,321,158
Trainable params: 2,321,158
Non-trainable params: 0
_________________________________________________________________
Inputs: (None, 10, 2)
Outputs: (None, 3802)
Actual input: (41185, 10, 2)
Actual output: (3802, 3802)
但是在我打电话之后:
history = self.model.fit(Input_train, Labels_train, shuffle=True, validation_data=(Input_test, Labels_test),
verbose=self.verbose)
发生以下错误:
ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 41185 arrays: [array([[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0....
我的错误是什么?
答案 0 :(得分:0)
将每个2D数组转换为1D,然后尝试将其提供给LSTM,并在检索时将其转换回2D。