[英]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.我注意到Keras 密集层的定义说:激活 function 使用。 If you don't specify anything, no activation is applied (ie. "linear" activation: a(x) = x).
如果您不指定任何内容,则不会应用任何激活(即“线性”激活: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!太感谢了!
Yes if there is no activation it's just a linear layer.是的,如果没有激活它只是一个线性层。
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. model.add (Dense(10, activation = None))
或nn.linear(128, 10)
是相同的,因为它在两者中都没有激活,因此如果您不指定任何内容,则不会应用激活。 It is so:!!原来如此:!! :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.