miroblog / deep_rl_trader

Trading Environment(OpenAI Gym) + DDQN (Keras-RL)
411 stars 92 forks source link

run on google colab "error" #3

Closed greg2paris closed 5 years ago

greg2paris commented 5 years ago

Hi, thank you for this implementation of reinforcement learning.

I created a google colab file. I succeded to run most of the code but I got an error at the very last part. This is the error im getting : `Training for 5500 steps ... start episode ... XBTUSD_5m_70000_train.csv at 0


ValueError Traceback (most recent call last)

in () 1 while True: 2 # train ----> 3 dqn.fit(env, nb_steps=5500, nb_max_episode_steps=10000, visualize=False, verbose=2) 4 try: 5 # validate /usr/local/lib/python3.6/dist-packages/rl/core.py in fit(self, env, nb_steps, action_repetition, callbacks, verbose, visualize, nb_max_start_steps, start_step_policy, log_interval, nb_max_episode_steps) 180 observation, r, done, info = self.processor.process_step(observation, r, done, info) 181 for key, value in info.items(): --> 182 if not np.isreal(value): 183 continue 184 if key not in accumulated_info: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()` How can I fix this? I shared the colab file so it can mabe help other people to. https://colab.research.google.com/drive/1DyURfsL9091Hx8IsEKwPGFxVl_aUEspp Thank you for your help, greg
raghavb commented 5 years ago

Hey @greg2paris, this is already asked and answered. Check this out: https://github.com/miroblog/deep_rl_trader/issues/2#issuecomment-475847223

greg2paris commented 5 years ago

Hey @greg2paris, this is already asked and answered. Check this out: #2 (comment)

Thank you bro, I managed to make it work. Wasn't easy cause you cant change python packages in google colab. So i had to make a copy of the github rl-keras in my google drive folder. Then i had to change all the "import" so i make sure it wont import the rl-keras that had been installed, and use the rl-keras I modified instead. Now everything is working. Thank you bro.

lorrp1 commented 4 years ago

how have you managed to get it working on colab? im getting many errors

greg2paris commented 4 years ago

yes, but you have to get a perfect environment to make it work in colab. When i tried to use global data for all the agent it wasnt working. Then you have to use the version 1.14 for the tensorflow and install stable baseline every time you run your agent

%tensorflow_version 1.14.0

!pip install tensorflow==1.14.0

import tensorflow print(tensorflow.version)

!pip install -q stable-baselines -U

and if u want to use the file inside your google drive you have to include this from google.colab import drive from google.colab import files import sys

This will prompt for authorization.

drive.mount("/content/gdrive")

current_directory_path = "/your_google_drive_files_path" sys.path.append(current_directory_path)

Every thing is working now. Good luck for your project.