How To Implement Gradient Ascent In A Keras Dqn
Have built a Reinforcement Learning DQN with variable length sequences as inputs, and positive and negative rewards calculated for actions. Some problem with my DQN model in Keras
Solution 1:
Writing a custom loss function
Here is the loss function you want
@tf.functiondefpositive_mse(y_true, y_pred):
return -1 * tf.keras.losses.MSE(y_true, y_pred)
And then your compile line becomes
model.compile(loss=positive_mse,
optimizer=Adam(lr=LEARNING_RATE, decay=DECAY),
metrics=[tf.keras.losses.MeanSquaredError()])
Please note : use loss=positive_mse
and not loss=positive_mse()
. That's not a typo. This is because you need to pass the function, not the results of executing the function.
Post a Comment for "How To Implement Gradient Ascent In A Keras Dqn"