| import torch | |
| import torch.nn as nn | |
| class AddModel(nn.Module): | |
| """ | |
| Input(2) -> Linear(32) -> ReLU -> Linear(64) -> ReLU -> Linear(1) -> Output | |
| """ | |
| def __init__(self): | |
| super(AddModel, self).__init__() | |
| self.fc1 = nn.Linear(2, 32) | |
| self.relu1 = nn.ReLU() | |
| self.fc2 = nn.Linear(32, 64) | |
| self.relu2 = nn.ReLU() | |
| self.fc3 = nn.Linear(64, 1) | |
| def forward(self, x): | |
| x = self.relu1(self.fc1(x)) | |
| x = self.relu2(self.fc2(x)) | |
| x = self.fc3(x) | |
| return x |