miroblog / deep_rl_trader

Trading Environment(OpenAI Gym) + DDQN (Keras-RL)
408 stars 91 forks source link

error when running model.fit #2

Open pongponglau opened 5 years ago

pongponglau commented 5 years ago

Thank you so much for this great project.

When i try to run ddqn_rl_trader.py on windows (my computer has no GPU, so i use LSTM instead of CuDNNLSTM), i get the following errors:

2019-01-17 17:06:16.101245: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary start episode ... XBTUSD_5m_70000_train.csv at 0 Traceback (most recent call last): File "ddqn_rl_trader.py", line 81, in main() File "ddqn_rl_trader.py", line 65, in main dqn.fit(env, nb_steps=5500, nb_max_episode_steps=10000, visualize=False, verbose=0) File "C:\Python36\lib\site-packages\rl\core.py", line 182, in fit if not np.isreal(value): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

May i ask what change i can make to this problem?

Thanks a lot

Jack30e commented 5 years ago

I'm having the same error... has anyone a solution?

ghost commented 5 years ago

@miroblog I am having the same issue. Do you have an idea?

(Pdb) dqn.fit(env, nb_steps=5500, nb_max_episode_steps=10000, visualize=False, verbose=2) Training for 5500 steps ... start episode ... XBTUSD_5m_70000_train.csv at 0 *** ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or

ENV_NAME = 'OHLCV-v0'
TIME_STEP = 30
PATH_TRAIN = "./data/train/"
PATH_TEST = "./data/test/"
env = OhlcvEnv(TIME_STEP, path=PATH_TRAIN)
env_test = OhlcvEnv(TIME_STEP, path=PATH_TEST)

def create_model(shape, nb_actions):
    model = Sequential()
    model.add(LSTM(64, input_shape=shape, return_sequences=True))
    model.add(LSTM(64))
    model.add(Dense(32))
    model.add(Activation('relu'))
    model.add(Dense(nb_actions, activation='linear'))
    return model
np.random.seed(123)
env.seed(123)

# create_model
nb_actions = env.action_space.n
model = create_model(shape=env.shape, nb_actions=nb_actions)
print(model.summary())

# create memory
memory = SequentialMemory(limit=50000, window_length=TIME_STEP)

# create policy
policy = EpsGreedyQPolicy()# policy = BoltzmannQPolicy()

# create agent
# you can specify the dueling_type to one of {'avg','max','naive'}

dqn = DQNAgent(model=model, nb_actions=nb_actions, memory=memory, nb_steps_warmup=200,  enable_dueling_network=True, dueling_type='avg', target_model_update=1e-2, policy=policy, processor=NormalizerProcessor())
dqn.compile(Adam(lr=1e-3), metrics=['mae'])

while True:
    # train
    pdb.set_trace()
    dqn.fit(env, nb_steps=5500, nb_max_episode_steps=10000, visualize=False, verbose=2)
GenesisGupta commented 5 years ago

pls change the file of C:\Python36\lib\site-packages\rl\core.py with the core.py file given here : deep_rl_trader/modified_keras_rl_core/

let me know in case you are facing any problems.

if somebody is wishing to collaborate on this , i am willing to collaborate

GenesisGupta commented 5 years ago

Hi,

I am not the owner of this project , but looking at creating a bot that can trade on itself.

I also trade crypto currencies using systematic trading models.

Regards, Nitin Gupta 9731423808

On Mon, Mar 25, 2019 at 4:48 PM Caner Çakmak notifications@github.com wrote:

@GenesisGupta https://github.com/GenesisGupta it works now, thank you. I am willing to colloborate in creating a binance trading bot with backtest and live trading that continuously trains on Open AI Gym. Could not see your contributions, are you the owner of the project?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/miroblog/deep_rl_trader/issues/2#issuecomment-476153583, or mute the thread https://github.com/notifications/unsubscribe-auth/Aam05pkCQ8XIkOtbXwN8AbBPiY0YADsLks5vaLCZgaJpZM4aEw7l .

raghavb commented 5 years ago

Hey, how did you guys install all the requirements? There are so many versions of dependencies that are not available. Any help would be highly appreciated. Thanks!

ghost commented 5 years ago

install in conda env, try installing the ones that don't work by removing the version tag

netvienna commented 5 years ago

pls change the file of C:\Python36\lib\site-packages\rl\core.py with the core.py file given here : deep_rl_trader/modified_keras_rl_core/

let me know in case you are facing any problems.

if somebody is wishing to collaborate on this , i am willing to collaborate

thx. On linux got to your environment folder /home/username.../anaconda3/envs/bt4ker/lib/python3.6/site-packages/rl/ and replace it. Then it works. Thx for the hint.