Keras: Can keras model be trained without label?

Created on 13 Sep 2017  ·  7Comments  ·  Source: keras-team/keras

Suppose I want to train a model to optimize a loss, but without a limited target, how can i train the model?

Most helpful comment

You still need an output, but in your loss function you can ignore the y_true. Then generate dummy values for the y values in the training call.

All 7 comments

You still need an output, but in your loss function you can ignore the y_true. Then generate dummy values for the y values in the training call.

Thanks, that's a good idea!

@ericwu09 or @Epiphqny , can you provide a sample code for the suggestion made?

@bhalajin just write your own loss function which does not use y_true, and set any value to y_true will make no difference

For instance:
def dummy_loss(y_true, y_pred): return y_pred

Tell me if I've got this wrong, but wouldn't it be a better idea to return y_true rather than y_pred? Surely using the predicted value as its own loss would just cause it to minimize its predictions, and by returning y_true couldn't you input the loss yourself directly when fitting?

@nwoodruff149 Only y_pred is based on your network; y_true has no relation with your network. Therefore, minimizing y_true is meaningless, as it is constant.

Was this page helpful?
0 / 5 - 0 ratings