Flatten

torch.nn.modules.flatten.Flatten
final class Flatten[D <: DType](startDim: Int, endDim: Int)(implicit evidence$1: Default[D]) extends TensorModule[D]

Flattens a contiguous range of dims into a tensor. For use with nn.Sequential.

Shape: - Input: $(, S_{\text{start}},..., S_{i}, ..., S_{\text{end}}, )$,' where $S_{i}$ is the size at dimension $i$ and $$ means any number of dimensions including none. - Output: $(, \prod_{i=\text{start}}^{\text{end}} S_{i}, *)$.

Example:

import torch.nn

val input = torch.randn(Seq(32, 1, 5, 5))
// With default parameters
val m1 = nn.Flatten()
// With non-default parameters
val m2 = nn.Flatten(0, 2)

Value parameters

endDim

last dim to flatten

startDim

first dim to flatten

Attributes

Source
Flatten.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

def apply(t: Tensor[D]): Tensor[D]

Attributes

Source
Flatten.scala
override def hasBias(): Boolean

Attributes

Definition Classes
Source
Flatten.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
Flatten.scala

Inherited methods

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 compose[A](g: A => Tensor[D]): A => R

Attributes

Inherited from:
Function1
def eval(): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

Inherited from:
Module
Source
Module.scala
def load(inputArchive: InputArchive): Unit

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

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
def parameters: Seq[Tensor[_]]

Attributes

Inherited from:
Module
Source
Module.scala
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
def save(outputArchive: OutputArchive): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Attributes

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

Attributes

Inherited from:
Module
Source
Module.scala
def train(on: Boolean): Unit

Attributes

Inherited from:
Module
Source
Module.scala

Concrete fields

override val nativeModule: FlattenImpl

Attributes

Source
Flatten.scala