sicara / easy-few-shot-learning

Ready-to-use code and tutorial notebooks to boost your way into few-shot learning for image classification.
MIT License
1.03k stars 141 forks source link

accuracy and loss #132

Closed HowCuteIsBee2002018 closed 6 months ago

HowCuteIsBee2002018 commented 9 months ago

Problem I want to ask is it a must to visualize both losses and accuracies of training and validation? And if so then i wanted to have see both results but however, the episodic notebook only has training loss and validation accuracy. is it possible to have

ebennequin commented 9 months ago

Yes. I don't see any reason why you couldn't. Just add the accuracy to the outputs of training_epoch() and the loss to the outputs of evaluate().

HowCuteIsBee2002018 commented 9 months ago

Training with visualization

average_loss = training_epoch(
    few_shot_classifier, train_loader, train_optimizer
)
train_losses.append(average_loss)

# Compute training accuracy after each epoch
train_accuracy = evaluate(
    few_shot_classifier, train_loader, device=DEVICE, tqdm_prefix="Training"
)
train_accuracies.append(train_accuracy)
print(f"Training Accuracy: {train_accuracy:.4f}")

# Validation Phase
val_loss = evaluate(
    few_shot_classifier, val_loader, device=DEVICE, tqdm_prefix="Validation"
)
val_losses.append(val_loss)

# Validation Accuracy
validation_accuracy = evaluate(
    few_shot_classifier, val_loader, device=DEVICE, tqdm_prefix="Validation"
)

can it be like this or the validation loss need to use the training epoch function to calculate the val loss?