from tensorflow.keras.models import Sequential
from tensorflow.keras.callbacks import EarlyStopping
from sklearn.model_selection import cross_val_score
def build_model():
model2=Sequential()
model2.add(LSTM(8,batch_input_shape=(12,12,1),stateful=True))
model2.add(Dense(8))
model2.add(Dense(8))
model2.add(Dense(1))
model2.compile(loss='mse',optimizer='adam')
return model2
model=KerasRegressor(build_fn=build_model, epochs=50, batch_size=12, verbose=0)
kfold = KFold(n_splits=5, random_state=np.random.seed(7))
score=cross_val_score(model,ts_x,ts_y,cv=kfold,scoring='neg_mean_squared_error')
ts_x.shape is (228,12,1)
ts_y.shape is (228,1,1)
As we can see here, I have 228 samples now,but when I run it:
ValueError: In a stateful network, you should only pass inputs with a number of samples that can be divided by the batch size. Found: 183 samples.
I want to know why it founded 183 samples instead 228 samples?