I am new to pytorch and I am trying to run a github model I found and test it. So the author's provided the model and the loss function.
like this:
#1. Inference the model
model = PhysNet_padding_Encoder_Decoder_MAX(frames=128)
rPPG, x_visual, x_visual3232, x_visual1616 = model(inputs)
#2. Normalized the Predicted rPPG signal and GroundTruth BVP signal
rPPG = (rPPG-torch.mean(rPPG)) /torch.std(rPPG) # normalize
BVP_label = (BVP_label-torch.mean(BVP_label)) /torch.std(BVP_label) # normalize
#3. Calculate the loss
loss_ecg = Neg_Pearson(rPPG, BVP_label)
Dataloading
train_loader = torch.utils.data.DataLoader(train_set, batch_size = 20, shuffle = True)
batch = next(iter(train_loader))
data, label1, label2 = batch
inputs= data
Let's say I want to train this model for 15 epochs. So this is what I have so far: I am trying to set the optimizer and training, but I am not sure how to tie the custom loss and data loading to the model and set the 15 epoch training correctly.
optimizer = optim.SGD(model.parameters(), lr=0.001, momentum=0.9)
for epoch in range(15):
....
Any suggestions?