2
$\begingroup$

Is this telling the model that there are two dimensions (i.e. it’s a matrix) but we don’t yet know the size of that particular dimension? If so, how can the model be compiled? Doesn’t the size of each dimension affect the number of nodes in middle layers?

$\endgroup$
5
$\begingroup$

In tf.keras, a None dimension means that it can be any scalar number, so that you use this model to infer on an arbitrarily long input. This dimension does not affect the size of the network, it just denotes that you are free to select the length (number of samples) of your input during testing.

$\endgroup$
0
$\begingroup$

You are almost right. However, in your specific examples (None,) and (None,12), we actually do know the size of the model's input and that's why the model can be compiled. (None,) refers to scalar inputs and (None,12) refers to 12-dimensional input vectors. Therefore, one can think of None as an adjustable variable/placeholder for the batch size of your model's optimization algorithm.

A more specific example: if the batch-size during model optimization/training is 32, then None will take one the value 32 and your model's input will be of size (32,12).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.