-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cloudpickle for experiment API method_call (#821)
- use cloudpickle for method_call dump/loads - add integration test for examples/
- Loading branch information
Showing
4 changed files
with
43 additions
and
2 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
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
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
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,38 @@ | ||
""" | ||
This is an integration test to make sure scripts from examples/ | ||
work when running `python examples/xx/xxx.py`. | ||
""" | ||
from garage.experiment import LocalRunner, run_experiment | ||
from garage.np.baselines import LinearFeatureBaseline | ||
from garage.tf.algos import VPG | ||
from garage.tf.envs import TfEnv | ||
from garage.tf.policies import CategoricalMLPPolicy | ||
|
||
|
||
def _run_task(snapshot_config, *_): | ||
with LocalRunner(snapshot_config=snapshot_config) as runner: | ||
env = TfEnv(env_name='CartPole-v1') | ||
|
||
policy = CategoricalMLPPolicy( | ||
name='policy', env_spec=env.spec, hidden_sizes=(32, 32)) | ||
|
||
baseline = LinearFeatureBaseline(env_spec=env.spec) | ||
|
||
algo = VPG( | ||
env_spec=env.spec, | ||
policy=policy, | ||
baseline=baseline, | ||
max_path_length=100, | ||
discount=0.99, | ||
optimizer_args=dict(tf_optimizer_args=dict(learning_rate=0.01, ))) | ||
|
||
runner.setup(algo, env) | ||
runner.train(n_epochs=3, batch_size=100) | ||
|
||
|
||
if __name__ == '__main__': | ||
run_experiment( | ||
_run_task, | ||
snapshot_mode='last', | ||
seed=1, | ||
) |