Get startedGet started for free

Loss weighting

Three versions of the two-output model for alphabet and character prediction that you built before have been trained: model_a, model_b, and model_c. For all three, the loss was defined as follows:

loss_alpha = criterion(outputs_alpha, labels_alpha)
loss_char = criterion(outputs_char, labels_char)
loss = ((1 - char_weight) * loss_alpha) + (char_weight * loss_char)

However, each of the three models was trained with a different char_weight: 0.1, 0.5, or 0.9.

Use the function you have defined in the previous exercise, evaluate_model(), to check the accuracy of each model. Which char_weight was used to train which model?

This exercise is part of the course

Intermediate Deep Learning with PyTorch

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise