Slide 28
Slide 28 text
Copyright © GREE, Inc. All Rights Reserved.
• 普通のKerasと同じような書き⽅
• modelのcompile
• fit
Keras-RL
使い⽅
env = gym.make(ʻCartPole-v0ʼ)
model = Sequential()
model.add(Flatten(input_shape=(1,) + env.observation_space.shape))
model.add(Dense(16))
model.add(Activation('relu'))
model.add(Dense(16))
model.add(Activation('relu'))
model.add(Dense(env.action_space.n))
model.add(Activation('linear'))
memory = SequentialMemory(limit=40000, window_length=1)
policy = EpsGreedyQPolicy()
dqn = DQNAgent(model=model, nb_actions=nb_actions, memory=memory, nb_steps_warmup=10,
policy=policy)
dqn.compile(Adam(lr=1e-3), metrics=['mae'])
dqn.fit(env, nb_steps=50000)
dqn.test(env, nb_episodes=5)