In Keras, why is it that input_shape
does not include the batch dimension when passed as an argument to layers like Dense
but DOES include the batch dimension when input_shape
is passed to the build
method of a model?
import tensorflow as tf
from tensorflow.keras.layers import Dense
if __name__ == "__main__":
model1 = tf.keras.Sequential([Dense(1, input_shape=[10])])
model1.summary()
model2 = tf.keras.Sequential([Dense(1)])
model2.build(input_shape=[None, 10]) # why [None, 10] and not [10]?
model2.summary()
Is this a conscious choice of API design? If it is, why?
from Why is it that `input_shape` does not include the batch dimension when passed as an argument to the `Dense` layer?
No comments:
Post a Comment