Weird loss value on validation set in assignment #2

Hello,

I’m still stuck with assignment #2. When I calculate the loss of the validation data of my module, I get the following result: 719766311.7573494 which means I got a problem since it’s not a reasonable value. I think the problem is in class InsuranceModel(nn.Module), and I’d really appreciate it if anyone could take a look (especially at the forward function) and help me out, I can’t find my mistake:

class InsuranceModel(nn.Module):
def __init__(self):
    super().__init__()
    self.linear = nn.Linear(input_size, output_size)                  # fill this (hint: use input_size & output_size defined above)
    
def forward(self, xb):
    xb = xb.reshape(-1, 7)
    out = self.linear(xb.float())                          # fill this
    return out

def training_step(self, batch):
    inputs, targets = batch 
    # Generate predictions
    out = self(inputs)          
    # Calcuate loss
    loss = F.mse_loss(out, targets)                          # fill this
    return loss

def validation_step(self, batch):
    inputs, targets = batch
    # Generate predictions
    out = self(inputs)
    # Calculate loss
    loss = F.mse_loss(out, targets)                           # fill this    
    return {'val_loss': loss.detach()}

Thank you

You use MSE loss.

Mean Squared Error. So your error is squared (to the power of 2).

Use L1 loss or just accept that loss will look like this when using MSE.