tenzr::nn::Sequential¶
Container module that applies its layers in order.
#include <sequential.h>
Inherits from tenzr::nn::Module
Public Functions¶
| Name | |
|---|---|
| Sequential() =default | |
| Sequential(std::initializer_list< std::shared_ptr< Module > > modules) | |
| void | Add(std::shared_ptr< Module > module) |
| void | Add(std::string name, std::shared_ptr< Module > module) |
| virtual Tensor | Forward(const Tensor & input) override |
| size_t | Size() const |
| bool | Empty() const |
| std::shared_ptr< Module > | operator[](size_t index) |
| const std::shared_ptr< Module > & | operator[](size_t index) const |
| virtual std::string | Name() const override |
Additional inherited members¶
Public Functions inherited from tenzr::nn::Module
| Name | |
|---|---|
| virtual | ~Module() =default |
| Tensor | operator()(const Tensor & input) |
| virtual void | Train(bool mode) |
| void | Train() Switch to training mode. |
| void | Eval() Switch to evaluation mode. |
| bool | IsTraining() const |
| Tensor & | RegisterParameter(std::string name, Tensor param) |
| template <typename T ,typename... Args> std::shared_ptr< T > |
RegisterSubmodule(std::string name, Args &&... args) |
| std::shared_ptr< Module > | RegisterSubmodule(std::string name, std::shared_ptr< Module > submod) |
| std::vector< Tensor > | Parameters(bool recurse =true) const |
| std::unordered_map< std::string, Tensor > | NamedParameters(std::string prefix ="", bool recurse =true) const |
| std::unordered_map< std::string, Tensor > | StateDict() const |
| void | LoadStateDict(const std::unordered_map< std::string, Tensor > & state) |
Protected Attributes inherited from tenzr::nn::Module
| Name | |
|---|---|
| std::unordered_map< std::string, Tensor > | parameters_ |
| std::unordered_map< std::string, std::shared_ptr< Module > > | submodules_ |
| bool | training_ |
Public Functions Documentation¶
function Sequential¶
function Sequential¶
Parameters:
- modules Layers to add in order.
Build a sequential container from an ordered list of modules, named by position.
function Add¶
Parameters:
Append a module with an auto-generated name. Append a module, naming it after its current position.
function Add¶
Parameters:
- name Submodule name.
- module Module to append.
- name Submodule name.
- module Module to add; must not be null.
Append a named module. Append a module under an explicit name.
function Forward¶
Parameters:
- input Input tensor.
- input Input tensor.
Return:
- Output of the last layer.
- Output of the final layer.
Reimplements: tenzr::nn::Module::Forward
Run input through each layer in order. Run input through every layer in order.
function Size¶
Return: Number of layers.
function Empty¶
Return: true when the container has no layers.
function operator[]¶
function operator[]¶
function Name¶
Return: "Sequential".
Reimplements: tenzr::nn::Module::Name