0
$\begingroup$

I'm reading several keras tutorials and found that many examples are written like this:

keras.Input(shape=(None,), dtype="int64", name="english")

Why do they use shape=(None,) instead of just shape=(None)?

I know that here None means any value. But, why are they writing that extra comma?

$\endgroup$

1 Answer 1

2
$\begingroup$

The Keras expects the shape argument to be tuple. And in python if you write shape =(None) and check its datatype with type(shape) you will get the output as int. However, if you write shape=(None,), it's considered as a tuple containing one element which is None.

So basically, the extra comma is used to define a tuple with one element.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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