machin.model¶
nets¶
machin.model.nets
provides implementations for various popular network
architectures.
-
class
machin.model.nets.
NeuralNetworkModule
[source]¶ Bases:
torch.nn.modules.module.Module
,abc.ABC
- Note: input device and output device are determined by module parameters,
your input module / output submodule should not store parameters on more than one device, and you also should not move your output to other devices other than your parameter storage device in forward().
Initializes internal Module state, shared by both nn.Module and ScriptModule.
-
set_input_module
(input_module)[source]¶ Set the input submodule of current module.
- Parameters
input_module (torch.nn.modules.module.Module) –
-
set_output_module
(output_module)[source]¶ Set the output submodule of current module.
- Parameters
output_module (torch.nn.modules.module.Module) –
-
property
input_device
¶
-
property
output_device
¶
-
forward
(*_)[source]¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
-
training
= None¶
-
machin.model.nets.
dynamic_module_wrapper
(wrapped_module)[source]¶ Wrapped module must locate on one single device, but could be moved around.
Input device and output device are automatically detected.
- Parameters
wrapped_module (torch.nn.modules.module.Module) –
-
machin.model.nets.
static_module_wrapper
(wrapped_module, input_device, output_device)[source]¶ Wrapped module could locate on multiple devices, but must not be moved.
Input device and output device are statically specified by user.
- Parameters
wrapped_module (torch.nn.modules.module.Module) –
torch.device] input_device (Union[str,) –
torch.device] output_device (Union[str,) –
-
class
machin.model.nets.
ResNet
(in_planes, depth, out_planes, out_pool_size=1, 1, norm='none')[source]¶ Bases:
machin.model.nets.base.NeuralNetworkModule
Create a resnet of specified depth.
- Parameters
in_planes (int) – Number of input planes.
depth (int) – Depth of resnet. Could be one of
18, 34, 50, 101, 152
.out_planes (int) – Number of output planes.
out_pool_size – Size of pooling output
norm – Normalization method, could be one of “none”, “batch” or “weight”.
-
training
= None¶
-
forward
(x)[source]¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.