machine-learning-for-trading icon indicating copy to clipboard operation
machine-learning-for-trading copied to clipboard

shape mismatch: value array of shape (4096,) could not be broadcast to indexing result of shape (2,4096,3)

Open defc0n1 opened this issue 3 years ago • 3 comments

Trying to run 04_q_learning_for_trading results in the following error:

118 print(targets.shape)
119 print(targets)

--> 120 q_values[[self.idx, actions]] = targets 122 loss = self.online_network.train_on_batch(x=states, y=q_values) 123 self.losses.append(loss)

ValueError: shape mismatch: value array of shape (4096,) could not be broadcast to indexing result of shape (2,4096,3)

Running tensorflow 2.9.2 (GPU)

defc0n1 avatar Jul 30 '22 17:07 defc0n1

Same here... have you found a solution?

dannyleall avatar Aug 23 '22 17:08 dannyleall

Same issue

dereklegenzoff avatar Aug 28 '22 01:08 dereklegenzoff

I changed the line in the error message to this:q_values[self.idx, actions] = targets

So far it seems to be working for me.

dereklegenzoff avatar Sep 01 '22 03:09 dereklegenzoff

There have been several updates to the open AI gym since publication. Please either use the version that was current at publication (around 2020/06) or update the code accordingly.

stefan-jansen avatar Jan 03 '23 01:01 stefan-jansen

https://www.facebook.com/mxalgrito?mibextid=ZbWKwL IP??

El sáb., 30 de julio de 2022 10:17, defc0n1 @.***> escribió:

Trying to run 04_q_learning_for_trading results in the following error:

118 print(targets.shape) 119 print(targets)

--> 120 q_values[[self.idx, actions]] = targets 122 loss = self.online_network.train_on_batch(x=states, y=q_values) 123 self.losses.append(loss)

ValueError: shape mismatch: value array of shape (4096,) could not be broadcast to indexing result of shape (2,4096,3)

Running tensorflow 2.9.2 (GPU)

— Reply to this email directly, view it on GitHub https://github.com/stefan-jansen/machine-learning-for-trading/issues/251, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATHPZIMC37NLIGZ2L2OGNUTVWVPR5ANCNFSM55DQP4LA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ghostMike666 avatar Jan 03 '23 01:01 ghostMike666