python - mismatch in input_shape and model structure -
this code:
model = sequential() model.add(lstm(24, input_shape = (trainx.shape[0], 1, 4))) model.add(dense(12, activation = 'softmax')) model.compile(loss='mean_squared_error', optimizer='adam') model.fit(trainx, trainy, epochs=100, batch_size=1, verbose=2) and after running, got this:
valueerror: input 0 incompatible layer lstm_5: expected ndim=3, found ndim=4 can explain me? , relationship between input_shape , model structure.
your input_shape should (trainx.shape[1], trainx.shape[2]). trainx.shape[0] number of training samples, input_shape doesn't care about; input_shape cares dimension of each sample, in form (timesteps, features).
model.add(lstm(24, input_shape = (trainx.shape[1], trainx.shape[2])))
Comments
Post a Comment