Keras: Sample weights for validation data causing val_loss to go to nan

Created on 15 May 2017  路  7Comments  路  Source: keras-team/keras

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.

stale

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)

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NancyZxll picture NancyZxll  路  3Comments

kylemcdonald picture kylemcdonald  路  3Comments

farizrahman4u picture farizrahman4u  路  3Comments

amityaffliction picture amityaffliction  路  3Comments

LuCeHe picture LuCeHe  路  3Comments