pythonlessons / RL-Bitcoin-trading-bot

Trying to create Reinforcement Learning powered Bitcoin trading bot
MIT License
380 stars 208 forks source link

'Adam' object has no attribute 'get_updates' #25

Closed Pray-d closed 9 months ago

Pray-d commented 9 months ago

C:\Users\G15\Desktop\tradingbotRL\env\lib\site-packages\keras\src\engine\training_v1.py:2359: UserWarning: Model.state_updates will be removed in a future version. This property should not be used in TensorFlow 2.0, as updates are applied automatically. updates=self.state_updates, 2023-11-30 19:38:24.841936: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-11-30 19:38:24.863100: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:388] MLIR V1 optimization pass is not enabled 2023-11-30 19:38:24.898453: W tensorflow/c/c_api.cc:305] Operation '{name:'dense_15/kernel/Assign' id:566 op device:{requested: '', assigned: ''} def:{{{node dense_15/kernel/Assign}} = AssignVariableOp[_has_manual_control_dependencies=true, dtype=DT_FLOAT, validate_shape=false](dense_15/kernel, dense_15/kernel/Initializer/stateless_random_uniform)}}' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session. 2023-11-30 19:38:25.816994: W tensorflow/c/c_api.cc:305] Operation '{name:'dense_7/BiasAdd' id:272 op device:{requested: '', assigned: ''} def:{{{node dense_7/BiasAdd}} = BiasAdd[T=DT_FLOAT, _has_manual_control_dependencies=true, data_format="NHWC"](dense_7/MatMul, dense_7/BiasAdd/ReadVariableOp)}}' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session. Traceback (most recent call last): File "C:\Users\G15\Desktop\tradingbotRL\bot.py", line 313, in train_agent(train_env, visualize=False, train_episodes=20000, training_batch_size=500) File "C:\Users\G15\Desktop\tradingbotRL\bot.py", line 273, in train_agent env.replay(states, actions, rewards, predictions, dones, next_states) File "C:\Users\G15\Desktop\tradingbotRL\bot.py", line 213, in replay a_loss = self.Actor.Actor.fit(states, y_true, epochs=self.epochs, verbose=0, shuffle=True) File "C:\Users\G15\Desktop\tradingbotRL\env\lib\site-packages\keras\src\engine\training_v1.py", line 856, in fit return func.fit( File "C:\Users\G15\Desktop\tradingbotRL\env\lib\site-packages\keras\src\engine\training_arrays_v1.py", line 734, in fit return fit_loop( File "C:\Users\G15\Desktop\tradingbotRL\env\lib\site-packages\keras\src\engine\training_arrays_v1.py", line 192, in model_iteration f = _make_execution_function(model, mode) File "C:\Users\G15\Desktop\tradingbotRL\env\lib\site-packages\keras\src\engine\training_arrays_v1.py", line 620, in _make_execution_function return model._make_execution_function(mode) File "C:\Users\G15\Desktop\tradingbotRL\env\lib\site-packages\keras\src\engine\training_v1.py", line 2366, in _make_execution_function self._make_train_function() File "C:\Users\G15\Desktop\tradingbotRL\env\lib\site-packages\keras\src\engine\training_v1.py", line 2284, in _make_train_function updates = self.optimizer.get_updates( AttributeError: 'Adam' object has no attribute 'get_updates'

pythonlessons commented 9 months ago

I think you ignored tensorflow==2.3.1 requirement

Pray-d commented 9 months ago

i just added legacy :=>>>>from tensorflow.keras.optimizers.legacy import Adam, RMSprop

Pray-d commented 9 months ago

i just added legacy :=>>>>from tensorflow.keras.optimizers.legacy import Adam, RMSprop and it is working now thanks