In this video, we will see how to use a custom loss function. Most 🤗 Transformers models automatically return the loss when you provide them with labels, but sometimes, you don’t want the default loss. Here we show how to dynamically weight samples in the loss using the Trainer API and 🤗 Accelerate.

This video is part of the Hugging Face course: http://huggingface.co/course
Open in colab to run the code samples:
https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/videos/custom_loss.ipynb

Related videos:
– The Trainer API: https://youtu.be/nvBXf7s7vTI
– Write your training loop in PyTorch: https://youtu.be/Dh9CL8fyG80
– Supercharge your PyTorch training loop with Accelerate: https://youtu.be/s7dy8QRgjJ0

Don’t have a Hugging Face account? Join now: http://huggingface.co/join
Have a question? Checkout the forums: https://discuss.huggingface.co/c/course/20
Subscribe to our newsletter: https://huggingface.curated.co/

Add comment

Your email address will not be published. Required fields are marked *

Categories

All Topics