# How to determine the sample weights for the loss function

**URL:** <https://community.deeplearning.ai/t/how-to-determine-the-sample-weights-for-the-loss-function/21968>\
**Category:** Structuring Machine Learning Projects\
**Tags:** coursera-platform\
**Created:** [July 19, 2021, 8:23am UTC](https://community.deeplearning.ai/t/how-to-determine-the-sample-weights-for-the-loss-function/21968 "2021-07-19T08:23:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andree](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@andree](https://community.deeplearning.ai/u/andree)\
**Post date:** [July 19, 2021, 8:23am UTC](https://community.deeplearning.ai/t/how-to-determine-the-sample-weights-for-the-loss-function/21968/1 "2021-07-19T08:23:21Z")

</div>

In the video ’ When to Change Dev/Test Sets and Metrics?’ A.N. talks about weighting the samples by a factor of w(i). For example giving porn images weight 1 and normal 10. Then using these weights in training within the loss function. But how to determine these weights? Are you suggesting to train a porn/not-porn classifier a priori?

---

<div class="post-metadata">

**Author:** ![manifest](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/manifest/32/62_2.png) [@manifest](https://community.deeplearning.ai/u/manifest)\
**Post date:** [July 19, 2021, 12:56pm UTC](https://community.deeplearning.ai/t/how-to-determine-the-sample-weights-for-the-loss-function/21968/2 "2021-07-19T12:56:27Z")

</div>

> [@andree](#):
>
> Are you suggesting to train a porn/not-porn classifier a priori?

Hey @andree, welcome to the DLS discussion forums 🙂

The assumption is that you already have some intuition about the data distribution of your training set, so you may assign some weight to each target label.

---

<div class="post-metadata">

**Author:** ![andree](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@andree](https://community.deeplearning.ai/u/andree)\
**Post date:** [July 19, 2021, 4:36pm UTC](https://community.deeplearning.ai/t/how-to-determine-the-sample-weights-for-the-loss-function/21968/3 "2021-07-19T16:36:57Z")

</div>

Ok, thanks, makes sense.
