Linear

torch.nn.modules.linear.Linear
final class Linear[ParamType <: FloatNN](inFeatures: Long, outFeatures: Long, addBias: Boolean)(implicit evidence$1: Default[ParamType]) extends HasParams[ParamType], HasWeight[ParamType], TensorModule[ParamType]

Applies a linear transformation to the incoming data: $y = xA^T + b$

This module supports TensorFloat32<tf32_on_ampere>.

Example:

import torch.*

val linear = nn.Linear[Float32](20, 30)
val input = torch.rand(Seq(128, 20))
println(linear(input).size) // ArraySeq(128, 30)

Value parameters

bias

If set to false, the layer will not learn an additive bias. Default: true

inFeatures

size of each input sample

outFeatures

size of each output sample

Attributes

Source
Linear.scala
Graph
Supertypes
trait TensorModule[ParamType]
trait Tensor[ParamType] => Tensor[ParamType]
trait HasWeight[ParamType]
trait HasParams[ParamType]
class Module
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def apply(input: Tensor[ParamType]): Tensor[ParamType]

Attributes

Source
Linear.scala
def bias: Tensor[ParamType]

Attributes

Source
Linear.scala
def bias_=(t: Tensor[ParamType]): Tensor[ParamType]

Attributes

Source
Linear.scala
override def hasBias(): Boolean

Attributes

Definition Classes
Source
Linear.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
Linear.scala
def weight: Tensor[ParamType]

Attributes

Source
Linear.scala
def weight_=(t: Tensor[ParamType]): Tensor[ParamType]

Attributes

Source
Linear.scala

Inherited methods

def andThen[A](g: Tensor[ParamType] => 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[ParamType]): 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
transparent inline def paramType: DType

Attributes

Inherited from:
HasParams
Source
Module.scala
override def parameters(recurse: Boolean): Seq[Tensor[ParamType]]

Attributes

Definition Classes
Inherited from:
HasParams
Source
Module.scala
override def parameters: Seq[Tensor[ParamType]]

Attributes

Definition Classes
Inherited from:
HasParams
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