nn.ModuleList()
-
[pytorch] MLP model source code by pythonAI 2020. 4. 24. 16:57
아래는 pytorch로 작성한 MLP모델의 소스코드이다. class MLPModel(nn.Module): def __init__(self, in_dim, out_dim, hid_dim, n_layer, act): super(MLPModel, self).__init__() self.in_dim = in_dim self.out_dim = out_dim self.hid_dim = hid_dim self.n_layer = n_layer self.act = act self.fc = nn.Linear(self.in_dim, self.hid_dim) self.linears = nn.ModuleList() for i in range(self.n_layer-1): self.linears.append(nn.Linear(s..