joxeankoret icon

Untitled

joxeankoret | PRO | 09/17/18 07:26:27 PM UTC | 0 ⭐ | 495 👁️ | Never ⏰ | []
Python |

840 B

|

None

|

0 👍

/

0 👎

(...)
import torch
import torch.nn.functional as func
(...)
#-------------------------------------------------------------------------------
class CPigaiosNet(torch.nn.Module):
  def __init__(self, D_in, H, D_out):
    super(CPigaiosNet, self).__init__()
    self.lin_lay1 = torch.nn.Linear(D_in, H)
    self.lin_lay2 = torch.nn.Linear(H, H/2)
    self.lin_lay3 = torch.nn.Linear(H/2, 1)
 
  def forward(self, inputs):
    a_lay1 = func.relu(self.lin_lay1(inputs))
    a_lay2 = func.relu(self.lin_lay2(a_lay1))
    return self.lin_lay3(a_lay2)
(...)
def train(self, checkpoint):
    x, y = self.load_data()
(...)
    self.model = CPigaiosNet(self.D_in, self.H, self.D_out)
    self.model.to(self.device)
    self.criterion = torch.nn.MSELoss(reduction='sum')
    self.optimizer = torch.optim.Adagrad(self.model.parameters(), lr=1e-4)
(...)

Comments