Advertisement
joxeankoret

Untitled

Sep 17th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. (...)
  2. import torch
  3. import torch.nn.functional as func
  4. (...)
  5. #-------------------------------------------------------------------------------
  6. class CPigaiosNet(torch.nn.Module):
  7.   def __init__(self, D_in, H, D_out):
  8.     super(CPigaiosNet, self).__init__()
  9.     self.lin_lay1 = torch.nn.Linear(D_in, H)
  10.     self.lin_lay2 = torch.nn.Linear(H, H/2)
  11.     self.lin_lay3 = torch.nn.Linear(H/2, 1)
  12.  
  13.   def forward(self, inputs):
  14.     a_lay1 = func.relu(self.lin_lay1(inputs))
  15.     a_lay2 = func.relu(self.lin_lay2(a_lay1))
  16.     return self.lin_lay3(a_lay2)
  17. (...)
  18. def train(self, checkpoint):
  19.     x, y = self.load_data()
  20. (...)
  21.     self.model = CPigaiosNet(self.D_in, self.H, self.D_out)
  22.     self.model.to(self.device)
  23.     self.criterion = torch.nn.MSELoss(reduction='sum')
  24.     self.optimizer = torch.optim.Adagrad(self.model.parameters(), lr=1e-4)
  25. (...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement