简体   繁体   中英

Batch size in model.fit and input shape in Keras

In keras documentation, input tensor for dense layer takes the input as:

Input shape

nD tensor with shape: (batch_size, ..., input_dim) . The most common situation would be a 2D input with shape (batch_size, input_dim) .

To my understanding, batch size in input tensor is the amount of examples you give for training or predicting.

For the batch_size in model.fit ,

batch_size: Integer or None . Number of samples per gradient update. If unspecified, batch_size will default to 32.

So are the 2 batch size doing the same thing, reducing the input data so as to prevent memory from filling up completely?
Also, I understand that the batch_size in input shape is optional, as keras puts a None if not specified. Is specifying batch_size necessary in model.fit ?

Both batch_size arguments are referring to the same thing, ie what you described as how many examples to feed into the model at once.

As for your other answer, it is not necessary for the model.fit function from the official keras website ( https://keras.io/models/model/ ) under the model.fit function "batch_size: Integer or None. Number of samples per gradient update. If unspecified, batch_size will default to 32" similar to the input shape.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM