Семинар 2, решение
unknown
python
19 days ago
770 B
5
Indexable
Never
class Network(nn.Module): def __init__(self, in_features, out_features): super().__init__() self.linear1 = nn.Linear(in_features, 256) self.relu = nn.ReLU() self.linear2 = nn.Linear(256, 128) self.leakyrelu = nn.LeakyReLU() self.linear3 = nn.Linear(640, 256) self.tanh = nn.Tanh() self.linear4 = nn.Linear(256, out_features) self.softmax = nn.Softmax() def forward(self, x): x1 = self.linear1(x) x1 = self.relu(x1) x2 = self.linear2(x1) x2 = self.leakyrelu(x2) x3 = torch.concat([x, x2], dim=1) x3 = self.linear3(x3) x3 = self.tanh(x3) x4 = x1 + x3 x4 = self.linear4(x4) y = self.softmax(x4) return y
Leave a Comment