-
Notifications
You must be signed in to change notification settings - Fork 803
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e7f0e7
commit 7b3a6ad
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline | ||
from rllab.envs.normalized_env import normalize | ||
from sandbox.rocky.tf.envs.base import TfEnv | ||
from sandbox.rocky.tf.policies.gaussian_mlp_policy import GaussianMLPPolicy | ||
from sandbox.rocky.tf.algos.trpo import TRPO | ||
from rllab.misc.instrument import stub, run_experiment_lite | ||
from rllab.envs.gym_env import GymEnv | ||
import sys | ||
|
||
stub(globals()) | ||
|
||
from rllab.misc.instrument import VariantGenerator, variant | ||
|
||
|
||
class VG(VariantGenerator): | ||
|
||
@variant | ||
def step_size(self): | ||
return [0.01, 0.05, 0.1] | ||
|
||
@variant | ||
def seed(self): | ||
return [1, 11, 21, 31, 41] | ||
|
||
variants = VG().variants() | ||
|
||
for v in variants: | ||
|
||
env = TfEnv(normalize(GymEnv('HalfCheetah-v1', record_video=False, record_log=False))) | ||
|
||
policy = GaussianMLPPolicy( | ||
env_spec=env.spec, | ||
# The neural network policy should have two hidden layers, each with 32 hidden units. | ||
hidden_sizes=(32, 32), | ||
name="policy" | ||
) | ||
|
||
baseline = LinearFeatureBaseline(env_spec=env.spec) | ||
|
||
algo = TRPO( | ||
env=env, | ||
policy=policy, | ||
baseline=baseline, | ||
batch_size=4000, | ||
max_path_length=100, | ||
n_itr=40, | ||
discount=0.99, | ||
step_size=v["step_size"], | ||
# Uncomment both lines (this and the plot parameter below) to enable plotting | ||
# plot=True, | ||
) | ||
|
||
run_experiment_lite( | ||
algo.train(), | ||
exp_prefix="first_exp", | ||
# Number of parallel workers for sampling | ||
n_parallel=1, | ||
# Only keep the snapshot parameters for the last iteration | ||
snapshot_mode="last", | ||
# Specifies the seed for the experiment. If this is not provided, a random seed | ||
# will be used | ||
seed=v["seed"], | ||
# mode="local", | ||
mode="ec2", | ||
variant=v, | ||
# plot=True, | ||
# terminate_machine=False, | ||
) | ||
sys.exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters