Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TutorGym
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teachable AI Lab
TutorGym
Commits
4ab8a209
Commit
4ab8a209
authored
4 years ago
by
Chris MacLellan
Browse files
Options
Downloads
Patches
Plain Diff
forgot to include ppo example
parent
f9fe3bdd
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test_ppo.py
+35
-0
35 additions, 0 deletions
test_ppo.py
with
35 additions
and
0 deletions
test_ppo.py
0 → 100644
+
35
−
0
View file @
4ab8a209
import
gym
from
stable_baselines.common.policies
import
MlpPolicy
from
stable_baselines.common
import
make_vec_env
from
stable_baselines
import
PPO2
import
tutorenvs
import
numpy
as
np
if
__name__
==
"
__main__
"
:
# multiprocess environment
env
=
make_vec_env
(
'
FractionArith-v0
'
,
n_envs
=
8
)
model
=
PPO2
(
MlpPolicy
,
env
,
verbose
=
0
,
gamma
=
0.5
,
tensorboard_log
=
"
./ppo_FractionArith-v0/
"
)
while
True
:
model
.
learn
(
total_timesteps
=
999999999
)
# model.save("ppo2_cartpole")
# del model # remove to demonstrate saving and loading
# model = PPO2.load("ppo2_cartpole")
# Enjoy trained agent
# obs = env.reset()
# rwd = 0
# for _ in range(100):
# action, _states = model.predict(obs)
# obs, rewards, dones, info = env.step(action)
# rwd += np.sum(rewards)
# # env.render()
# print(rwd)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment