Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Philipp Sauer
alf
Commits
8753b8bb
Commit
8753b8bb
authored
3 years ago
by
Break Yang
Browse files
Options
Downloads
Patches
Plain Diff
Convert ppo_cart_pole to python configuration
parent
1bfcf5fc
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
alf/examples/ppo_cart_pole_conf.py
+60
-0
60 additions, 0 deletions
alf/examples/ppo_cart_pole_conf.py
with
60 additions
and
0 deletions
alf/examples/ppo_cart_pole_conf.py
0 → 100644
+
60
−
0
View file @
8753b8bb
# Copyright (c) 2021 Horizon Robotics and ALF Contributors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
alf
from
alf.examples
import
ppo_conf
from
alf.algorithms.data_transformer
import
RewardScaling
from
alf.networks
import
ActorDistributionNetwork
,
ValueNetwork
from
alf.utils.losses
import
element_wise_huber_loss
# Environment Configuration
alf
.
config
(
'
create_environment
'
,
env_name
=
'
CartPole-0
'
,
num_parallel_environments
=
8
)
# Reward Scailing
alf
.
config
(
'
TrainerConfig
'
,
data_transformer_ctor
=
RewardScaling
)
alf
.
config
(
'
RewardScaling
'
,
scale
=
0.01
)
# algorithm config
alf
.
config
(
'
ActorDistributionNetwork
'
,
fc_layer_params
=
(
100
,
))
alf
.
config
(
'
ValueNetwork
'
,
fc_layer_params
=
(
100
,
))
alf
.
config
(
'
ActorCriticAlgorithm
'
,
actor_network_ctor
=
ActorDistributionNetwork
,
value_network_ctor
=
ValueNetwork
,
optimizer
=
alf
.
optimizers
.
Adam
(
lr
=
1e-3
))
alf
.
config
(
'
PPOLoss
'
,
entropy_regularization
=
1e-4
,
gamma
=
0.98
,
td_error_loss_fn
=
element_wise_huber_loss
,
normalize_advantages
=
False
)
# training config
alf
.
config
(
'
TrainerConfig
'
,
mini_batch_length
=
1
,
unroll_length
=
32
,
mini_batch_size
=
128
,
num_updates_per_train_iter
=
4
,
num_iterations
=
600
,
num_checkpoints
=
5
,
evaluate
=
True
,
eval_interval
=
50
,
debug_summaries
=
False
,
summary_interval
=
5
)
alf
.
config
(
'
ReplayBuffer
'
,
max_length
=
2048
)
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