I tried for looping the batch sizes to know the effect of batch sizes in the model.
print ('train_X', train_X.shape)
print ('test_X', test_X.shape)
print ('train_Y', train_Y.shape)
print ('test_Y', test_Y.shape)
model = Sequential()
model.add(Dense(64, input_dim=size, activation='relu'))
model.add(Dense(7))
batch_sizes = [32,64,128,256,512]
for batch_size in batch_sizes:
model.compile(optimizer="adam", loss="mean_squared_error")
history = model.fit(train_X,
train_Y,
epochs=3,
validation_data=(test_X, test_Y),
batch_size=batch_size,
verbose=2)
It did work well for the first batch size, but then it failed. Please see the validation loss.
Epoch 1/3
212/212 - 8s - loss: 0.4929 - val_loss: 0.1251
Epoch 2/3
212/212 - 7s - loss: 0.0121 - val_loss: 0.3445
Epoch 3/3
212/212 - 7s - loss: 0.0114 - val_loss: 0.2329
The second loop failed with strange val_loss.
Epoch 1/3
106/106 - 6s - loss: 0.3061 - val_loss: 694288384.0000
Epoch 2/3
106/106 - 6s - loss: 0.0114 - val_loss: 694312320.0000
Epoch 3/3
106/106 - 5s - loss: 0.0108 - val_loss: 694323264.0000
Any idea to implement it correctly.