SOS
SOS

Reputation: 539

Is there a difference between Keras Dense layer and Pytorch's nn.linear layer?

I noticed the definition of Keras Dense layer says: Activation function to use. If you don't specify anything, no activation is applied (ie. "linear" activation: a(x) = x).

So if we have a code like:

model.add(Dense(10, activation = None))

Is it basically the same as:

nn.linear(128, 10)

?

Thank you so much!

Upvotes: 2

Views: 2400

Answers (2)

Erling Olsen
Erling Olsen

Reputation: 740

Yes, it is the same. model.add (Dense(10, activation = None)) or nn.linear(128, 10) is the same, because it is not activated in both, therefore if you don't specify anything, no activation is applied. It is so!!! :)

Upvotes: 2

ashutosh singh
ashutosh singh

Reputation: 533

Yes if there is no activation it's just a linear layer.

Upvotes: 1

Related Questions