I’m trying to work out the MAE and MSE values for my model. Please can someone confirm that i am using this the correct formula?
mae = torch.abs(preds - targets).sum().data
mse = ((preds - targets)*(preds - targets)).sum().data
mae = mae.detach() / len(loader_test)
MAE_for_all_epochs.append(mae.item())
mse = math.sqrt(loss / len(loader_test))
MSE_for_all_epochs.append(mse)
print("MAE: %f" % mae)
print("MSE: %f" % mse)
MSE_for_all_epochs = sum(MSE_for_all_epochs)
MAE_for_all_epochs = sum(MAE_for_all_epochs)
print(MAE_for_all_epochs)
print(MSE_for_all_epochs)
model_mae= MSE_for_all_epochs / (epoch + 1)
model_mse= MAE_for_all_epochs / (epoch + 1)
print("Model MAE: %f" % model_mae)
print("Model MSE: %f" % model_mse)
Many Thanks