trw.simple_layers.simple_layers_implementations
¶
Module Contents¶
Classes¶
Represent an input (i.e., a feature) to a network |
|
Output class for classification |
|
Create an embedding for display purposes |
|
Generic module |
|
Generic module |
|
Generic module |
|
Base class for all neural network modules. |
|
Reshape a tensor to another shape |
|
Generic module |
|
Generic module |
|
Generic module |
|
Generic module |
|
Generic module |
|
Generic module |
|
Implement a channel concatenation layer |
Functions¶
|
|
|
|
|
- class trw.simple_layers.simple_layers_implementations.Input(shape: list, feature_name: str)¶
Bases:
trw.simple_layers.simple_layers.SimpleLayerBase
Represent an input (i.e., a feature) to a network
- get_module(self)¶
Return a nn.Module
- class trw.simple_layers.simple_layers_implementations.OutputClassification(node, output_name, classes_name, **kwargs)¶
Bases:
trw.simple_layers.simple_layers.SimpleOutputBase
Output class for classification
- forward(self, inputs, batch)¶
Create a trw.train.Output from the inputs
- Parameters
inputs – a list of inputs of the output node
batch – the batch of data fed to the network
- Returns
a trw.train.Output object
- get_module(self)¶
Return a nn.Module
- trw.simple_layers.simple_layers_implementations.return_output(outputs, batch)¶
- class trw.simple_layers.simple_layers_implementations.OutputEmbedding(node, output_name, functor=None)¶
Bases:
trw.simple_layers.simple_layers.SimpleOutputBase
Create an embedding for display purposes
- forward(self, inputs, batch)¶
Create a trw.train.Output from the inputs
- Parameters
inputs – a list of inputs of the output node
batch – the batch of data fed to the network
- Returns
a trw.train.Output object
- get_module(self)¶
Return a nn.Module
- class trw.simple_layers.simple_layers_implementations.ReLU(node)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- class trw.simple_layers.simple_layers_implementations.BatchNorm2d(node, eps=1e-05, momentum=0.1, affine=True)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- class trw.simple_layers.simple_layers_implementations.BatchNorm3d(node, eps=1e-05, momentum=0.1, affine=True)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- class trw.simple_layers.simple_layers_implementations._Reshape(shape)¶
Bases:
torch.nn.Module
Base class for all neural network modules.
Your models should also subclass this class.
Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:
import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x))
Submodules assigned in this way will be registered, and will have their parameters converted too when you call
to()
, etc.- Variables
training (bool) – Boolean represents whether this module is in training or evaluation mode.
- forward(self, x)¶
- class trw.simple_layers.simple_layers_implementations.Reshape(node, shape)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Reshape a tensor to another shape
- class trw.simple_layers.simple_layers_implementations.Linear(node, out_features)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- class trw.simple_layers.simple_layers_implementations.Flatten(node)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- trw.simple_layers.simple_layers_implementations._conv_2d_shape_fn(node, module_args)¶
- class trw.simple_layers.simple_layers_implementations.Conv2d(node, out_channels, kernel_size, stride=1, padding='same')¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- trw.simple_layers.simple_layers_implementations._conv_3d_shape_fn(node, module_args)¶
- class trw.simple_layers.simple_layers_implementations.Conv3d(node, out_channels, kernel_size, stride=1, padding='same')¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- class trw.simple_layers.simple_layers_implementations.MaxPool2d(node, kernel_size, stride=None)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- class trw.simple_layers.simple_layers_implementations.MaxPool3d(node, kernel_size, stride=None)¶
Bases:
trw.simple_layers.simple_layers.SimpleModule
Generic module
Module must have a single input and all the module’s parameters should be on the same device.
- class trw.simple_layers.simple_layers_implementations.ConcatChannels(nodes, flatten=False)¶
Bases:
trw.simple_layers.simple_layers.SimpleMergeBase
Implement a channel concatenation layer
- static calculate_shape(parents)¶
- get_module(self)¶
Return a nn.Module