Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zuoxingdong committed Sep 4, 2018
1 parent ce9dfb3 commit d2d64bf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 54 deletions.
73 changes: 35 additions & 38 deletions lagom/core/networks/make_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@
def make_fc(input_dim, hidden_sizes):
r"""Returns a ModuleList of fully connected layers.
Args:
input_dim (int): input dimension in the first fully connected layer.
hidden_sizes (list): a list of hidden sizes, each for one fully connected layer.
Returns
-------
fc : nn.ModuleList
A ModuleList of fully connected layers.
.. note::
All submodules can be automatically tracked because it uses nn.ModuleList. One can
use this function to generate parameters in :class:`BaseNetwork`.
Example::
>>> make_fc(3, [4, 5, 6])
Expand All @@ -26,7 +17,15 @@ def make_fc(input_dim, hidden_sizes):
(1): Linear(in_features=4, out_features=5, bias=True)
(2): Linear(in_features=5, out_features=6, bias=True)
)
Args:
input_dim (int): input dimension in the first fully connected layer.
hidden_sizes (list): a list of hidden sizes, each for one fully connected layer.
Returns
-------
fc : nn.ModuleList
A ModuleList of fully connected layers.
"""
assert isinstance(hidden_sizes, list), f'expected as list, got {type(hidden_sizes)}'

Expand All @@ -47,18 +46,6 @@ def make_fc(input_dim, hidden_sizes):
def make_cnn(input_channel, channels, kernels, strides, paddings):
r"""Returns a ModuleList of 2D convolution layers.
Args:
input_channel (int): input channel in the first convolution layer.
channels (list): a list of channels, each for one convolution layer.
kernels (list): a list of kernels, each for one convolution layer.
strides (list): a list of strides, each for one convolution layer.
paddings (list): a list of paddings, each for one convolution layer.
Returns
-------
cnn : nn.ModuleList
A ModuleList of 2D convolution layers.
.. note::
All submodules can be automatically tracked because it uses nn.ModuleList. One can
Expand All @@ -71,7 +58,18 @@ def make_cnn(input_channel, channels, kernels, strides, paddings):
(0): Conv2d(3, 16, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1))
(1): Conv2d(16, 32, kernel_size=(3, 3), stride=(1, 1))
)
Args:
input_channel (int): input channel in the first convolution layer.
channels (list): a list of channels, each for one convolution layer.
kernels (list): a list of kernels, each for one convolution layer.
strides (list): a list of strides, each for one convolution layer.
paddings (list): a list of paddings, each for one convolution layer.
Returns
-------
cnn : nn.ModuleList
A ModuleList of 2D convolution layers.
"""
N = len(channels)

Expand Down Expand Up @@ -103,19 +101,6 @@ def make_cnn(input_channel, channels, kernels, strides, paddings):
def make_transposed_cnn(input_channel, channels, kernels, strides, paddings, output_paddings):
r"""Returns a ModuleList of 2D transposed convolution layers.
Args:
input_channel (int): input channel in the first transposed convolution layer.
channels (list): a list of channels, each for one transposed convolution layer.
kernels (list): a list of kernels, each for one transposed convolution layer.
strides (list): a list of strides, each for one transposed convolution layer.
paddings (list): a list of paddings, each for one transposed convolution layer.
output_paddings (list): a list of output paddings, each for one transposed convolution layer.
Returns
-------
transposed_cnn : nn.ModuleList
A ModuleList of 2D transposed convolution layers.
.. note::
All submodules can be automatically tracked because it uses nn.ModuleList. One can
Expand All @@ -133,7 +118,19 @@ def make_transposed_cnn(input_channel, channels, kernels, strides, paddings, out
(0): ConvTranspose2d(3, 16, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1), output_padding=(1, 1))
(1): ConvTranspose2d(16, 32, kernel_size=(3, 3), stride=(1, 1))
)
Args:
input_channel (int): input channel in the first transposed convolution layer.
channels (list): a list of channels, each for one transposed convolution layer.
kernels (list): a list of kernels, each for one transposed convolution layer.
strides (list): a list of strides, each for one transposed convolution layer.
paddings (list): a list of paddings, each for one transposed convolution layer.
output_paddings (list): a list of output paddings, each for one transposed convolution layer.
Returns
-------
transposed_cnn : nn.ModuleList
A ModuleList of 2D transposed convolution layers.
"""
N = len(channels)

Expand Down
17 changes: 1 addition & 16 deletions lagom/core/policies/random_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,8 @@ class RandomPolicy(BasePolicy):
Example::
from lagom.envs import make_gym_env
from lagom.envs import make_envs
from lagom.envs import EnvSpec
from lagom.envs.vec_env import SerialVecEnv
from lagom.core.policies import RandomPolicy
list_make_env = make_envs(make_env=make_gym_env,
env_id='CartPole-v1',
num_env=2,
init_seed=0)
venv = SerialVecEnv(list_make_env=list_make_env)
obs = venv.reset()
env_spec = EnvSpec(venv)
policy = RandomPolicy(config=None, network=None, env_spec=env_spec)
policy(obs)
policy(observation)
"""
def __call__(self, x):
Expand Down

0 comments on commit d2d64bf

Please sign in to comment.