Closed THINK989 closed 1 year ago
also need to add
from keras.layers import Lambda
@THINK989 I am testing the original code from the master branch with 15 years of OHLC data and a 1-year validation set. The eval on the model produced, shows about 50% accuracy on unseen data. I then saw your PR and incorporated your changes. After doing so, my training no longer finishes. I tried running it on a very large AWS EC2 instance with 256 GB RAM, but it still runs out of memory. I also reduced the data set from 15 years to 5 years, but that didn't help either. Do you have any suggestions?
Hello @vimkp, thanks to you I remember this pull request was to be edited, due to some changes made after the pull request, if you are looking for a quick solution then this might help
def _model(self):
"""Creates the model"""
X_input = Input((self.state_size,))
X = Dense(units = 128, activation="relu",input_dim=self.state_size)(X_input)
X = Dense(units = 256, activation="relu")(X)
X = Dense(units = 256, activation="relu")(X)
X = Dense(units = 128, activation="relu")(X)
state_value = Dense(1, activation = "linear")(X)
state_value = Lambda(lambda s: K.expand_dims(s[:, 0], -1), output_shape=(self.action_size,))(state_value)
action_advantage = Dense(self.action_size, activation = "linear")(X)
action_advantage = Lambda(lambda a: a[:, :] - K.mean(a[:, :], keepdims=True), output_shape=(self.action_size,))(action_advantage)
out = Add()([state_value, action_advantage])
model = Model(inputs = X_input, outputs = out)
model.compile(loss=self.loss, optimizer=self.optimizer)
model.summary()
return model
I changed the whole model structure, and these are the necessary extra imports
from keras.models import Model
from keras.layers import Dense, Lambda, Input, Add
I will close the pull request since the commit changes made to the file were experimental and should have never been pushed
check _model(self) function, I have tried it and saw improvements when trained with double DQN approach i.e. Dueling Double DQN