add kukaCamGymEnv.py with camera observations (preliminary)
show camera position in example browser disable per-vertex and per-fragment profile timings
This commit is contained in:
33
examples/pybullet/gym/train_pybullet_cartpole.py
Normal file
33
examples/pybullet/gym/train_pybullet_cartpole.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import gym
|
||||
from envs.bullet.cartpole_bullet import CartPoleBulletEnv
|
||||
|
||||
from baselines import deepq
|
||||
|
||||
|
||||
def callback(lcl, glb):
|
||||
# stop training if reward exceeds 199
|
||||
is_solved = lcl['t'] > 100 and sum(lcl['episode_rewards'][-101:-1]) / 100 >= 199
|
||||
return is_solved
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
env = gym.make('CartPoleBulletEnv-v0')
|
||||
model = deepq.models.mlp([64])
|
||||
act = deepq.learn(
|
||||
env,
|
||||
q_func=model,
|
||||
lr=1e-3,
|
||||
max_timesteps=100000,
|
||||
buffer_size=50000,
|
||||
exploration_fraction=0.1,
|
||||
exploration_final_eps=0.02,
|
||||
print_freq=10,
|
||||
callback=callback
|
||||
)
|
||||
print("Saving model to cartpole_model.pkl")
|
||||
act.save("cartpole_model.pkl")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user