The same input, only different batch sizes.
- Why the outputs are different?
- How to avoid the difference or force the output to be the same?
from tensorflow import keras
from tensorflow.keras import layers
def create_net(n_input, n_hidden, activation=None):
seq = keras.Sequential(
[
layers.Dense(n_hidden, input_shape=(n_input,),
activation=activation,
),
layers.Dense(159*159,
)
]
)
return seq
seq2 = create_net(n_input=100000, n_hidden=50, activation='linear')
print(seq2.predict(np.ones((64, 100000)), batch_size=32)[0, :])
print(seq2.predict(np.ones((64, 100000)), batch_size=1)[0, :])
output:
[-0.10577075 -0.02522129 0.05591403 ... 0.07279566 -0.01813894
-0.03258121]
[-0.10577081 -0.02522125 0.05591398 ... 0.07279569 -0.01813904
-0.03258121]