ModuleList

torch.nn.modules.container.ModuleList
final class ModuleList[D <: DType](val modules: TensorModule[D]*) extends Module, TensorModule[D], Iterable[TensorModule[D]]

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
Graph
Supertypes
trait TensorModule[D]
trait Tensor[D] => Tensor[D]
class Module
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Appends a given module to the end of the list.

Appends a given module to the end of the list.

Value parameters

module

module to append

Attributes

Returns

ModuleList[D] with new elements

Source
ModuleList.scala
override def apply(input: Tensor[D]): Tensor[D]

Attributes

Definition Classes
Source
ModuleList.scala
def apply(i: Int): TensorModule[D]

Attributes

Source
ModuleList.scala

Appends modules from a Python iterable to the end of the list.

Appends modules from a Python iterable to the end of the list.

Value parameters

modules

iterable of modules to append

Attributes

Source
ModuleList.scala
override def hasBias(): Boolean

Attributes

Definition Classes
Source
ModuleList.scala

Insert a given module before a given index in the list.

Insert a given module before a given index in the list.

Value parameters

index

index to insert.

module

module to insert

Attributes

Returns

ModuleList[D] with new elements

Source
ModuleList.scala
override def iterator: Iterator[TensorModule[D]]

Attributes

Definition Classes
Source
ModuleList.scala
def length: Int

Attributes

Source
ModuleList.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Source
ModuleList.scala

Inherited methods

final def ++[B >: TensorModule[D]](suffix: IterableOnce[B]): CC[B]

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
IterableOnceOps
def andThen[A](g: Tensor[D] => A): T1 => A

Attributes

Inherited from:
Function1
def apply(fn: Module => Unit): Module.this.type

Attributes

Inherited from:
Module
Source
Module.scala
def collect[B](pf: PartialFunction[TensorModule[D], B]): CC[B]

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
IterableOnceOps
def compose[A](g: A => Tensor[D]): A => R

Attributes

Inherited from:
Function1
def concat[B >: TensorModule[D]](suffix: IterableOnce[B]): CC[B]

Attributes

Inherited from:
IterableOps
def copyToArray[B >: TensorModule[D]](xs: Array[B], start: Int, len: Int): Int

Attributes

Inherited from:
IterableOnceOps
def copyToArray[B >: TensorModule[D]](xs: Array[B], start: Int): Int

Attributes

Inherited from:
IterableOnceOps
def copyToArray[B >: TensorModule[D]](xs: Array[B]): Int

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
IterableOnceOps
def count(p: TensorModule[D] => Boolean): Int

Attributes

Inherited from:
IterableOnceOps
def drop(n: Int): C

Attributes

Inherited from:
IterableOps
def dropRight(n: Int): C

Attributes

Inherited from:
IterableOps
def dropWhile(p: TensorModule[D] => Boolean): C

Attributes

Inherited from:
IterableOps
override def empty: CC[A]

Attributes

Definition Classes
Inherited from:
IterableFactoryDefaults
def eval(): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
IterableOnceOps
def filter(pred: TensorModule[D] => Boolean): C

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
IterableOps
def find(p: TensorModule[D] => Boolean): Option[A]

Attributes

Inherited from:
IterableOnceOps
def flatMap[B](f: TensorModule[D] => IterableOnce[B]): CC[B]

Attributes

Inherited from:
IterableOps
def flatten[B](implicit asIterable: TensorModule[D] => IterableOnce[B]): CC[B]

Attributes

Inherited from:
IterableOps
def fold[A1 >: TensorModule[D]](z: A1)(op: (A1, A1) => A1): A1

Attributes

Inherited from:
IterableOnceOps
def foldLeft[B](z: B)(op: (B, TensorModule[D]) => B): B

Attributes

Inherited from:
IterableOnceOps
def foldRight[B](z: B)(op: (TensorModule[D], B) => B): B

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
IterableOnceOps
def foreach[U](f: TensorModule[D] => U): Unit

Attributes

Inherited from:
IterableOnceOps
protected def fromSpecific(coll: IterableOnce[TensorModule[D]]): CC[A]

Attributes

Inherited from:
IterableFactoryDefaults
def groupBy[K](f: TensorModule[D] => K): Map[K, C]

Attributes

Inherited from:
IterableOps
def groupMap[K, B](key: TensorModule[D] => K)(f: TensorModule[D] => B): Map[K, CC[B]]

Attributes

Inherited from:
IterableOps
def groupMapReduce[K, B](key: TensorModule[D] => K)(f: TensorModule[D] => B)(reduce: (B, B) => B): Map[K, B]

Attributes

Inherited from:
IterableOps
def grouped(size: Int): Iterator[C]

Attributes

Inherited from:
IterableOps
def head: A

Attributes

Inherited from:
IterableOps
def headOption: Option[A]

Attributes

Inherited from:
IterableOps
def init: C

Attributes

Inherited from:
IterableOps
def inits: Iterator[C]

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
Module
Source
Module.scala
override def isTraversableAgain: Boolean

Attributes

Definition Classes
Inherited from:
IterableOps

Attributes

Definition Classes
Inherited from:
Iterable
def knownSize: Int

Attributes

Inherited from:
IterableOnce
def last: A

Attributes

Inherited from:
IterableOps
def lastOption: Option[A]

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
Iterable
def load(inputArchive: InputArchive): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala
def map[B](f: TensorModule[D] => B): CC[B]

Attributes

Inherited from:
IterableOps
def max[B >: TensorModule[D]](implicit ord: Ordering[B]): A

Attributes

Inherited from:
IterableOnceOps
def maxBy[B](f: TensorModule[D] => B)(implicit cmp: Ordering[B]): A

Attributes

Inherited from:
IterableOnceOps
def maxByOption[B](f: TensorModule[D] => B)(implicit cmp: Ordering[B]): Option[A]

Attributes

Inherited from:
IterableOnceOps
def maxOption[B >: TensorModule[D]](implicit ord: Ordering[B]): Option[A]

Attributes

Inherited from:
IterableOnceOps
def min[B >: TensorModule[D]](implicit ord: Ordering[B]): A

Attributes

Inherited from:
IterableOnceOps
def minBy[B](f: TensorModule[D] => B)(implicit cmp: Ordering[B]): A

Attributes

Inherited from:
IterableOnceOps
def minByOption[B](f: TensorModule[D] => B)(implicit cmp: Ordering[B]): Option[A]

Attributes

Inherited from:
IterableOnceOps
def minOption[B >: TensorModule[D]](implicit ord: Ordering[B]): Option[A]

Attributes

Inherited from:
IterableOnceOps
final def mkString: String

Attributes

Inherited from:
IterableOnceOps
final def mkString(sep: String): String

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala
protected def newSpecificBuilder: Builder[A, CC[A]]

Attributes

Inherited from:
IterableFactoryDefaults

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
Module
Source
Module.scala
def parameters: Seq[Tensor[_]]

Attributes

Inherited from:
Module
Source
Module.scala
def partition(p: TensorModule[D] => Boolean): (C, C)

Attributes

Inherited from:
IterableOps
def partitionMap[A1, A2](f: TensorModule[D] => Either[A1, A2]): (CC[A1], CC[A2])

Attributes

Inherited from:
IterableOps
def product[B >: TensorModule[D]](implicit num: Numeric[B]): B

Attributes

Inherited from:
IterableOnceOps
def reduce[B >: TensorModule[D]](op: (B, B) => B): B

Attributes

Inherited from:
IterableOnceOps
def reduceLeft[B >: TensorModule[D]](op: (B, TensorModule[D]) => B): B

Attributes

Inherited from:
IterableOnceOps
def reduceLeftOption[B >: TensorModule[D]](op: (B, TensorModule[D]) => B): Option[B]

Attributes

Inherited from:
IterableOnceOps
def reduceOption[B >: TensorModule[D]](op: (B, B) => B): Option[B]

Attributes

Inherited from:
IterableOnceOps
def reduceRight[B >: TensorModule[D]](op: (TensorModule[D], B) => B): B

Attributes

Inherited from:
IterableOnceOps
def reduceRightOption[B >: TensorModule[D]](op: (TensorModule[D], B) => B): Option[B]

Attributes

Inherited from:
IterableOnceOps
def register[M <: Module](child: M, n: String)(using name: Name): M

Attributes

Inherited from:
Module
Source
Module.scala

Adds a buffer to the module.

Adds a buffer to the module.

Attributes

Inherited from:
Module
Source
Module.scala
def registerBuffer[D <: DType](t: Tensor[D], n: String)(using name: Name): Tensor[D]

Attributes

Inherited from:
Module
Source
Module.scala
def registerModule[M <: Module](child: M, n: String)(using name: Name): M

Attributes

Inherited from:
Module
Source
Module.scala
def registerParameter[D <: DType](t: Tensor[D], requiresGrad: Boolean, n: String)(using name: Name): Tensor[D]

Attributes

Inherited from:
Module
Source
Module.scala
protected def reversed: Iterable[A]

Attributes

Inherited from:
IterableOnceOps
def save(outputArchive: OutputArchive): Unit

Attributes

Inherited from:
Module
Source
Module.scala
def scan[B >: TensorModule[D]](z: B)(op: (B, B) => B): CC[B]

Attributes

Inherited from:
IterableOps
def scanLeft[B](z: B)(op: (B, TensorModule[D]) => B): CC[B]

Attributes

Inherited from:
IterableOps
def scanRight[B](z: B)(op: (TensorModule[D], B) => B): CC[B]

Attributes

Inherited from:
IterableOps
def size: Int

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
IterableOps
final def sizeIs: SizeCompareOps

Attributes

Inherited from:
IterableOps
def slice(from: Int, until: Int): C

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
IterableOps
def sliding(size: Int): Iterator[C]

Attributes

Inherited from:
IterableOps
def span(p: TensorModule[D] => Boolean): (C, C)

Attributes

Inherited from:
IterableOps
override def splitAt(n: Int): (C, C)

Attributes

Definition Classes
Inherited from:
IterableOps
def stepper[S <: Stepper[_]](implicit shape: StepperShape[TensorModule[D], S]): S

Attributes

Inherited from:
IterableOnce
def sum[B >: TensorModule[D]](implicit num: Numeric[B]): B

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
Module
Source
Module.scala
def tail: C

Attributes

Inherited from:
IterableOps
def tails: Iterator[C]

Attributes

Inherited from:
IterableOps
def take(n: Int): C

Attributes

Inherited from:
IterableOps
def takeRight(n: Int): C

Attributes

Inherited from:
IterableOps
def takeWhile(p: TensorModule[D] => Boolean): C

Attributes

Inherited from:
IterableOps
override def tapEach[U](f: TensorModule[D] => U): C

Attributes

Definition Classes
Inherited from:
IterableOps
def to[C1](factory: Factory[TensorModule[D], C1]): C1

Attributes

Inherited from:
IterableOnceOps
def to(device: Device): Module.this.type

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
IterableOnceOps
final def toBuffer[B >: TensorModule[D]]: Buffer[B]

Attributes

Inherited from:
IterableOnceOps

Attributes

Inherited from:
IterableOnceOps
def toList: List[A]

Attributes

Inherited from:
IterableOnceOps
def toMap[K, V](implicit ev: TensorModule[D] <:< (K, V)): Map[K, V]

Attributes

Inherited from:
IterableOnceOps
def toSeq: Seq[A]

Attributes

Inherited from:
IterableOnceOps
def toSet[B >: TensorModule[D]]: Set[B]

Attributes

Inherited from:
IterableOnceOps
def toVector: Vector[A]

Attributes

Inherited from:
IterableOnceOps
def train(on: Boolean): Unit

Attributes

Inherited from:
Module
Source
Module.scala
def transpose[B](implicit asIterable: TensorModule[D] => Iterable[B]): CC[CC[B]]

Attributes

Inherited from:
IterableOps
def unzip[A1, A2](implicit asPair: TensorModule[D] => (A1, A2)): (CC[A1], CC[A2])

Attributes

Inherited from:
IterableOps
def unzip3[A1, A2, A3](implicit asTriple: TensorModule[D] => (A1, A2, A3)): (CC[A1], CC[A2], CC[A3])

Attributes

Inherited from:
IterableOps
def view: View[A]

Attributes

Inherited from:
IterableOps

Attributes

Inherited from:
IterableOps
def zip[B](that: IterableOnce[B]): CC[(A, B)]

Attributes

Inherited from:
IterableOps
def zipAll[A1 >: TensorModule[D], B](that: Iterable[B], thisElem: A1, thatElem: B): CC[(A1, B)]

Attributes

Inherited from:
IterableOps
def zipWithIndex: CC[(A, Int)]

Attributes

Inherited from:
IterableOps

Deprecated and Inherited methods

def ++:[B >: TensorModule[D]](that: IterableOnce[B]): CC[B]

Attributes

Deprecated
[Since version 2.13.0] Use ++ instead of ++: for collections of type Iterable
Inherited from:
IterableOps
final def /:[B](z: B)(op: (B, TensorModule[D]) => B): B

Attributes

Deprecated
[Since version 2.13.0] Use foldLeft instead of /:
Inherited from:
IterableOnceOps
final def :\[B](z: B)(op: (TensorModule[D], B) => B): B

Attributes

Deprecated
[Since version 2.13.0] Use foldRight instead of :\\
Inherited from:
IterableOnceOps
def aggregate[B](z: => B)(seqop: (B, TensorModule[D]) => B, combop: (B, B) => B): B

Attributes

Deprecated
[Since version 2.13.0] `aggregate` is not relevant for sequential collections. Use `foldLeft(z)(seqop)` instead.
Inherited from:
IterableOnceOps

Attributes

Deprecated
[Since version 2.13.0] Use iterableFactory instead
Inherited from:
IterableOps
final def copyToBuffer[B >: TensorModule[D]](dest: Buffer[B]): Unit

Attributes

Deprecated
[Since version 2.13.0] Use `dest ++= coll` instead
Inherited from:
IterableOnceOps

Attributes

Deprecated
[Since version 2.13.0] Check .knownSize instead of .hasDefiniteSize for more actionable information (see scaladoc for details)
Inherited from:
IterableOnceOps
final def repr: C

Attributes

Deprecated
[Since version 2.13.0] Use coll instead of repr in a collection implementation, use the collection value itself from the outside
Inherited from:
IterableOps
def seq: Iterable.this.type

Attributes

Deprecated
[Since version 2.13.0] Iterable.seq always returns the iterable itself
Inherited from:
Iterable
final def toIterable: Iterable.this.type

Attributes

Deprecated
[Since version 2.13.7] toIterable is internal and will be made protected; its name is similar to `toList` or `toSeq`, but it doesn\'t copy non-immutable collections
Inherited from:
Iterable
final def toIterator: Iterator[A]

Attributes

Deprecated
[Since version 2.13.0] Use .iterator instead of .toIterator
Inherited from:
IterableOnceOps
final def toStream: Stream[A]

Attributes

Deprecated
[Since version 2.13.0] Use .to(LazyList) instead of .toStream
Inherited from:
IterableOnceOps
final def toTraversable: Iterable[A]

Attributes

Deprecated
[Since version 2.13.0] toTraversable is internal and will be made protected; its name is similar to `toList` or `toSeq`, but it doesn\'t copy non-immutable collections
Inherited from:
IterableOps
def view(from: Int, until: Int): View[A]

Attributes

Deprecated
[Since version 2.13.0] Use .view.slice(from, until) instead of .view(from, until)
Inherited from:
IterableOps

Concrete fields

override val modules: TensorModule[D]*

Attributes

Source
ModuleList.scala