如果我有这个神经网络(NN):
class NeuralNet(nn.Module):
def __init__(self, input_size, hidden_size, num_classes, p=dropout):
super(NeuralNet, self).__init__()
self.fc1 = nn.Linear(input_size, hidden_size)
self.fc2 = nn.Linear(hidden_size, hidden_size)
self.fc3 = nn.Linear(hidden_size, num_classes)
self.dropout = nn.Dropout(p=p)
def forward(self, x):
out = F.relu(self.fc1(x))
out = F.relu( self.dropout(self.fc2(out)))
out = self.fc3(out)
return out
你如何增加偏见?例如,在隐藏层上。我在网上找不到任何东西
这取决于您使用的图层。有些人没有这种选择。例如,在“线性”中,可以使用:
在the documentation中,您可以看到其他类型的层是否具有偏移选项
相关问题 更多 >
编程相关推荐