mRoszak commited on
Commit
22477ac
1 Parent(s): ab331fc

Upload a2c_sb3_cartpole.py

Browse files
Files changed (1) hide show
  1. a2c_sb3_cartpole.py +20 -0
a2c_sb3_cartpole.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gym
2
+
3
+ from stable_baselines3 import A2C
4
+ from stable_baselines3.common.env_util import make_vec_env
5
+
6
+ # Parallel environments
7
+ env = gym.make("CartPole-v1")
8
+
9
+ model = A2C("MlpPolicy", env, verbose=1)
10
+ model.learn(total_timesteps=25000)
11
+
12
+ obs = env.reset()
13
+ for i in range (10000):
14
+ action, _states = model.predict(obs)
15
+ obs, rewards, dones, info = env.step(action)
16
+ env.render()
17
+
18
+ env.close()
19
+
20
+ model.save("a2c_Cart_Pole")