Reputation: 3
I am working through a course on deep learning with Python and ran into this line:
hidden = Dense(2)(visible)
What does the second parameter do? Is this a python language feature I've missed?
Upvotes: 0
Views: 39
Reputation: 19310
I remember asking the same thing when I was learning Keras.
hidden = Dense(2)(visible)
You can rewrite this in a more verbose way as below:
dense_layer = Dense(2)
hidden = dense_layer(visible)
As you can see from the above, the first line creates an instance of the Dense
layer, and then you can call that layer on a tensor. This adds the Dense
operation to a graph of operations.
Upvotes: 2
Reputation: 1105
Visible
is not a language specific feature or something. Your code should not have only this line but before that you probably define a variable named visible
like below.
from keras.layers import Input
from keras.layers import Dense
visible = Input(shape=(2,))
hidden = Dense(2)(visible)
Here are some examples:
Upvotes: 0