【问题标题】:I am studying artificial neural networks. Where is the hidden layer?我正在研究人工神经网络。隐藏层在哪里?
【发布时间】:2021-12-21 14:04:12
【问题描述】:
class MLP(nn.Module):
  def __init__(self):
    super().__init__()

    self.in_dim = 28 * 28
    self.out_dim = 10

    self.fc1 =nn.Linear(self.in_dim,512)
    self.fc2=nn.Linear(512, 256)
    self.fc3 =nn.Linear(256, 128)
    self.fc4 =nn.Linear(128, 64)
    self.fc5 =nn.Linear(64, self.out_dim)

    self.relu = nn.ReLU()

  def forward(self, x):
      a1 = self.relu(self.fc1(x.view(-1,self.in_dim)))      
      a2 = self.relu(self.fc2(a1))
      a3 = self.relu(self.fc3(a2))
      a4 = self.relu(self.fc4(a3))
      logit = self.fc5(a4)

      return logit

真的很基础,但是听完解释我很困惑,所以我问。 看上面的代码,

如果是隐藏层,a1,a2,a3,a4是否正确?

x 是输入值, 我们认为a1是x乘以fc(权重)的结果,a2是对a1应用激活函数的结果。

【问题讨论】:

  • 看起来你有多个隐藏层。

标签: python deep-learning jupyter-notebook artificial-intelligence


【解决方案1】:

考虑到隐藏层位于输入和输出层之间。我不得不说隐藏层,在这种情况下,它将是 a2 和 a3。

【讨论】:

  • 不是a4吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-21
  • 2019-12-13
  • 2015-07-04
  • 1970-01-01
  • 2011-11-19
相关资源
最近更新 更多