I keep hearing that batch_size does not influence the accuracy or quality of learning.
But in my simple model, using a batch_size of 20,000 (total dataset 2.5 million) right away gives me a loss of NaN and 0.004 accuracy. Decreasing the bath_size to 2,000 will give me a loss of 4.10 and accuracy of 0.07, and the accuracy continues to increase appropriately with each epoch as expected.
So: does the fact that my batch_size affects the accuracy mean that my model is set up wrong?
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.optimizers import SGD
model = Sequential()
model.add(Dense(26, activation='relu', input_dim=X.shape[1]))
model.add(Dropout(0.1))
model.add(Dense(Y.shape[1], activation='softmax'))
sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
optimizer=sgd,
metrics=['accuracy',])
model.fit(X, Y,epochs=15,batch_size=2000)
score = model.evaluate(X, Y, batch_size=2000)
score
Epoch 1/15
44s - loss: 4.7164 - acc: 0.0781
Epoch 2/15
45s - loss: 4.3305 - acc: 0.0977
Epoch 3/15
45s - loss: 4.1886 - acc: 0.1065
Epoch 4/15
45s - loss: 4.1235 - acc: 0.1104
Epoch 5/15
45s - loss: 4.0881 - acc: 0.1122
Epoch 6/15
45s - loss: 4.0657 - acc: 0.1136
Epoch 7/15
45s - loss: 4.0506 - acc: 0.1148
Epoch 8/15
45s - loss: 4.0393 - acc: 0.1154
Epoch 9/15
47s - loss: 4.0305 - acc: 0.1159
Epoch 10/15
model.fit(X, Y,epochs=15,batch_size=200000)
score = model.evaluate(X, Y, batch_size=200000)
score
Epoch 1/15
42s - loss: NaN - acc: 0.0004