Categories
Misc

layer doesn’t create weights when given input shape

In The Sequential model | TensorFlow Core section Specifying the input shape in advance it says:

Generally, all layers in Keras need to know the shape of their inputs in order to be able to create their weights. So when you create a layer like this, initially, it has no weights:

“`python layer = layers.Dense(3) print(layer.weights) # Empty

Output

[] “`

But if I specify the input_shape, why the output is still empty?

“`python layer = layers.Dense(2, input_shape=(4,))

print(layer.weights) # Still empty “`

submitted by /u/Ynjxsjmh
[visit reddit] [comments]

Leave a Reply

Your email address will not be published.