Closed ShakthiYasas closed 3 years ago
This was resolved as follows by making the following code change:
def optimizer(self):
action = K.placeholder(dtype=float, shape=(None, 5))
discounted_rewards = K.placeholder(shape=(None,))
# Calculate cross entropy error function
action_prob = K.sum(action * self.model.output, axis=1)
cross_entropy = K.log(action_prob) * discounted_rewards
loss = -K.sum(cross_entropy)
# create training function
optimizer = Adam(lr=self.learning_rate)
updates = optimizer.get_updates(params=self.model.trainable_weights, loss=loss)
train = K.function(inputs=[self.model.input, action, discounted_rewards], outputs=self.model.output, updates=updates)
return train
Hey all!
I get the following issue running, reinforce_agent.py and all of under, 3-atari. Prior to this, this same lines caused, Tensor to Numpy array issue which was resolved by adding,
Provided above, I'm now faced with this issue. I've tried various solutions including using K.eval(loss) before, but that cause some other issue. My tensorfzlow version is 2.4.1, Keras version 2.4.3 and Numpy version 1.19.5.
Any solution to this? @Hyeokreal @keon