torch.nn.modules.container
package torch.nn.modules.container
Members list
Type members
Classlikes
final class ModuleList[D <: DType](val modules: TensorModule[D]*) extends Module, TensorModule[D], Iterable[TensorModule[D]]
Holds submodules in a list.
Holds submodules in a list.
It can be indexed like a regular Python list, but the modules it contains are properly registered, and will be visible by all torch.nn.Module methods.
Attributes
- See also
-
https://pytorch.org/docs/stable/generated/torch.nn.ModuleList.html?highlight=modulelist#torch.nn.ModuleList
- Example
-
class MyModule extends nn.Module: val linears = register( nn.ModuleList([nn.Linear(10, 10) for i in range(10)]) ) // ModuleList can act as an iterable, or be indexed using ints def forward(self, x) = var x_ = x.copy_(x) for l <- linears x_ = x_ + l(x_) x
- Source
- ModuleList.scala
- Supertypes
final class Sequential[D <: DType](val modules: TensorModule[D]*) extends Module, TensorModule[D]
Attributes
- Source
- Sequential.scala
- Supertypes
In this article