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
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 “`