Keras input layer shape matches any shape given by generator

Viewed 27

I found this strange behaviour that keras trains without error although the shapes do not match

n = Input(shape=(16, 1))
d = Dense(1, activation='sigmoid')(n)
m = Model(n, d)

def get_gen():
    for i in range(10):
         x = np.random.rand(32, 28, 1)
         yield x, np.ones(32)

m.fit(get_gen()) # Works strangely
m.fit(np.random.rand(32, 28, 1), np.ones(32)) # Not working reasonbly

So why input shape is not respected in case of generator, is there implicit broadcasting, I really can not comprehend this behaviour as it should raise error when input shapes mismatch

0 Answers
Related