when do you use Input shape vs batch_shape in kera

2019-06-26 08:11发布

问题:

I don't find API that explains keras Input.

When should you use shape attribute vs batch_shape attribute?

回答1:

From the Keras source code:

Arguments

    shape: A shape tuple (integer), not including the batch size.
        For instance, `shape=(32,)` indicates that the expected input
        will be batches of 32-dimensional vectors.
    batch_shape: A shape tuple (integer), including the batch size.
        For instance, `batch_shape=(10, 32)` indicates that
        the expected input will be batches of 10 32-dimensional vectors.
        `batch_shape=(None, 32)` indicates batches of an arbitrary number
        of 32-dimensional vectors.

The batch size is how many examples you have in your training data.

You can use any. Personally I never used "batch_shape". When you use "shape", your batch can be any size, you don't have to care about it.

shape=(32,) means exactly the same as batch_shape=(None,32)



标签: keras shape