Dropout

torch.nn.modules.regularization.Dropout
final class Dropout[ParamType <: FloatNN | ComplexNN](p: Double, inplace: Boolean)(implicit evidence$1: Default[ParamType]) extends HasParams[ParamType], TensorModule[ParamType]

During training, randomly zeroes some of the elements of the input tensor with probability p using samples from a Bernoulli distribution. Each channel will be zeroed out independently on every forward call.

This has proven to be an effective technique for regularization and preventing the co-adaptation of neurons as described in the paper Improving neural networks by preventing co-adaptation of feature detectors.

Furthermore, the outputs are scaled by a factor of $\frac{1}{1−p}​ during training. This means that during evaluation the module simply computes an identity function.

Shape:

  • Input: $(∗)(∗)$. Input can be of any shape
  • Output: $(∗)(∗)$. Output is of the same shape as input

Value parameters

inplace

– If set to True, will do this operation in-place. Default: false

p

– probability of an element to be zeroed. Default: 0.5

Attributes

See also
Example
import torch.nn
val m = nn.Dropout(p=0.2)
val input = torch.randn(20, 16)
val output = m(input)
Source
Dropout.scala
Graph
Supertypes
trait TensorModule[ParamType]
trait Tensor[ParamType] => Tensor[ParamType]
trait HasParams[ParamType]
class Module
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

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

Attributes

Source
Dropout.scala
override def hasBias(): Boolean

Attributes

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