我的模特:
model = Sequential()
model.add( LSTM(25, batch_input_shape = (None, None, 19), return_sequences = True ) )
model.add(Dense(4, activation = 'tanh'))
model.compile(loss='mean_squared_error', optimizer ='adam', metrics = ['accuracy'])
输入数据形状的一些示例:
input_list [0] .shape =(7,19)
input_list [1] .shape =(8,19)
input_list [2] .shape =(17,19)
输出数据形状的一些示例:
output_list [0] .shape =(7,4)
output_list [1] .shape =(8,4)
output_list [2] .shape =(17,4)
input_list.shape =(233,)
output_list.shape =(233,)
发生错误:
d_loss = model.fit(input_list,output_list,validation_split=0.33,nb_epoch=100,verbose=1,shuffle=True, batch_size = 1)
错误:ValueError:检查输入时出错:预期lstm_22_input具有3维,但数组的形状为(233,1)
答案 0 :(得分:0)
只需将尺寸增加np.expand_dims(x,axis = 0)。它将变成三维。