Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Theano-dependent code in garage.theano #245

Merged
19 commits merged into from
Aug 1, 2018
Merged

Conversation

ghost
Copy link

@ghost ghost commented Aug 1, 2018

The following modules were moved from garage.core into
garage.theano.core package:

  • lasagne_layers
  • lasagne_powered
  • network

Also, the module lasagne_helpers was removed since no other module in
the project makes reference to it, with the functions in lasagne.layers
used instead.

All the modules from garage.distribution package were moved into
garage.theano.distribution.

The following modules were moved from garage.algos into
garage.theano.algos package:

  • ddpg
  • erwr
  • npo
  • ppo
  • reps
  • tnpg
  • trpo
  • vpg

Regarding garage.misc, the module special.py is used by both the Theano
and TensorFlow packages, but it contained some Theano dependent
functions. Only those functions were moved into garage.theano.misc to
keep the rest of the functions for both distributions in the new module
tensor_utils.py. The same thing was done for ext.py.
The rest of the modules in garage.misc are independent of Theano.

All modules in garage.optimizers except for minibatch_dataset were moved
into the garage.theano.optimizers package.

All modules in garage.policies except for base were moved into the
garage.theano.policies package.

The module continuous_mlp_q_function was moved from garage.q_functions into the garage.theano.q_functions package.

All modules in garage.regressors except for product_regressor were moved
into the garage.theano.regressors package.

The class ReplayPool found in module utils from garage.sampler was
extracted from the module and moved to garage.theano.sampler.

For garage.envs, only the function new_tensor_variable in module util
makes use of Theano. It was removed since it's not called anywhere and
other versions of it in garage.theano.spaces in modules product, box and
discrete are called instead.

The following modules in garage.baselines were moved into the
garage.theano.baseline package:

  • gaussian_conv_baseline
  • gaussian_mlp_baseline

The corresponding imports for each moved module were modified as well.

Finally, all the PEP8 style errors were fixed.

@ghost ghost self-assigned this Aug 1, 2018
@ghost ghost requested review from eric-heiden, CatherineSue and jonashen August 1, 2018 05:05
@ghost ghost self-requested a review as a code owner August 1, 2018 05:05
@ghost
Copy link
Author

ghost commented Aug 1, 2018

There are some docstring errors produced by moved files, but that is fixed in #244.

@ryanjulian
Copy link
Member

Great work! Let me know if you need me to push this past the CI

@@ -272,12 +273,12 @@ def init_opt(self):
policy_updates = self.policy_update_method(
policy_reg_surr, self.policy.get_params(trainable=True))

f_train_qf = ext.compile_function(
f_train_qf = tensor_utils.compile_function(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason you switched ext to tensor_utils? Just curious.

Copy link
Author

@ghost ghost Aug 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we want to keep all the Theano-dependent code in garage.theano, and the module garage.misc.ext had both independent and Theano-dependent code, I moved all the latter code into the new module garage.theano.misc.tensor_utils to create the separation.
This is a particular case where not the whole module but only parts of it are only used by the Theano branch, while the other parts are used by both TensorFlow and Theano.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In generally we have like O(2^n) util.py files when we should really have like O(n), so i'm in favor of merging whichever ones make any sense.

Angel Gonzalez added 19 commits August 1, 2018 11:13
Remove Theano comments from layers.py, and replace theano log with
TensorFlow branch.
The following modules were moved into the garage.theano package:
- lasagne_layers
- lasagne_powered
- network

The corresponding imports were modified as well.

Also, the module lasagne_helpers was removed since no other module in
the project makes reference to it, with the functions in lasagne.layers
used instead.
While refactoring garage.core to separate the Theano-dependent code,
some PEP8 style errors were found.
All the modules from the distribution package were moved into
garage.theano.
While refactoring garage.distributions to separate the Theano-dependent
code, some PEP8 style errors were found.
The following modules were moved into the garage.theano package:
- ddpg
- erwr
- npo
- ppo
- reps
- tnpg
- trpo
- vpg

The corresponding imports were modified as well.
While refactoring garage.algos to separate the Theano-dependent code,
some PEP8 style errors were found.
The module special.py is used by both the Theano and TensorFlow
packages, but it contained some Theano dependent functions. Only those
functions were moved into garage.theano to keep the rest of the
functions for both distributions in the new module tensor_utils.py.
The same thing was done for ext.py.
The rest of the modules in garage.misc are independent of Theano.
While refactoring garage.misc to separate the Theano-dependent code,
some PEP8 style errors were found.
All modules in garage.optimizers except for minibatch_dataset were moved
into the garage.theano package.
The corresponding imports were modified as well.
All modules in garage.policies except for base were moved into the
garage.theano package.
The corresponding imports were modified as well.
The module continuous_mlp_q_function was moved into the garage.theano
package.
The corresponding imports were modified as well.
All modules in garage.regressors except for product_regressor were moved
into the garage.theano package.
The corresponding imports were modified as well.
The class ReplayPool found in module utils from garage.sampler, was
extracted from the module and moved to garage.theano.
The rest of the modules were not modified.
Only the function new_tensor_variable in module util makes use of
Theano. It was removed since it's not called anywhere and other versions
of it in garage.theano.spaces in modules product, box and discrete are
called instead.
The following modules were moved into the garage.theano package:
- gaussian_conv_baseline
- gaussian_mlp_baseline

The corresponding imports were modified as well.
The issues were produced during the refactor:
- The function flatten_tensors was called from the incorrect module.
- The function from_onehot_n may receive Numpy arrays and regular
arrays, so we need to verify the type before checking if the
corresponding array is empty.
@ghost ghost force-pushed the refactor_garage_theano branch from de9c758 to ba75aeb Compare August 1, 2018 18:15
@ghost ghost merged commit 941ae08 into master Aug 1, 2018
@ryanjulian
Copy link
Member

huzzah!

@ryanjulian ryanjulian deleted the refactor_garage_theano branch August 1, 2018 18:54
krzentner pushed a commit to krzentner/garage that referenced this pull request Nov 13, 2018
The following modules were moved from garage.core into
garage.theano.core package:

lasagne_layers
lasagne_powered
network
Also, the module lasagne_helpers was removed since no other module in
the project makes reference to it, with the functions in lasagne.layers
used instead.

All the modules from garage.distribution package were moved into
garage.theano.distribution.

The following modules were moved from garage.algos into
garage.theano.algos package:

ddpg
erwr
npo
ppo
reps
tnpg
trpo
vpg
Regarding garage.misc, the module special.py is used by both the Theano
and TensorFlow packages, but it contained some Theano dependent
functions. Only those functions were moved into garage.theano.misc to
keep the rest of the functions for both distributions in the new module
tensor_utils.py. The same thing was done for ext.py.
The rest of the modules in garage.misc are independent of Theano.

All modules in garage.optimizers except for minibatch_dataset were moved
into the garage.theano.optimizers package.

All modules in garage.policies except for base were moved into the
garage.theano.policies package.

The module continuous_mlp_q_function was moved from garage.q_functions into the garage.theano.q_functions package.

All modules in garage.regressors except for product_regressor were moved
into the garage.theano.regressors package.

The class ReplayPool found in module utils from garage.sampler was
extracted from the module and moved to garage.theano.sampler.

For garage.envs, only the function new_tensor_variable in module util
makes use of Theano. It was removed since it's not called anywhere and
other versions of it in garage.theano.spaces in modules product, box and
discrete are called instead.

The following modules in garage.baselines were moved into the
garage.theano.baseline package:

gaussian_conv_baseline
gaussian_mlp_baseline
The corresponding imports for each moved module were modified as well.

Finally, all the PEP8 style errors were fixed.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants