Using keras and theano, The val_loss metric is nan when I pass sample weights for validation data. The same issue arises when passing validation data parameter to the "fit" function as well as using the model.evaluate. Train loss is not nan irrespective of sample weights parameter but only val_loss goes to nan upon passing sample weights. Don't know if the same issue exists with tensorflow backend because I can't run my model with TF backend due to low gpu memory.
What is the type of your sample_weights ? If its a pandas.Series it will not work. I solved my issue by doing np.array(list(Z)) (Z being the sample_weights)
Any luck with this? I'm having the same issue.
I had the same problem and @daoudChami 's tip seems to have solved it. My sample_weight was a Pandas DataFrame before. Converting it to a Numpy array fixed the issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
@daoudChami 's solution seems to have worked for me too.
Weird problem though
confirmed issue exists with TF backend as well (in training). fixed by converting to numpy
This happens to me with a numpy array.
Most helpful comment
What is the type of your sample_weights ? If its a pandas.Series it will not work. I solved my issue by doing np.array(list(Z)) (Z being the sample_weights)