LayerScale

class LayerScale<T : DType, V>(val dim: Int, val name: String = "LayerScale", initScale: Tensor<T, V>? = null) : Module<T, V> , ModuleParameters<T, V> (source)

Layer Scale: element-wise multiplication by a learnable per-channel scalar.

Introduced in "Going deeper with Image Transformers" (CaiT). Used in vision transformers and audio codec decoders (Voxtral).

Parameters

dim

Number of channels

name

Module name

initScale

Initial scale tensor (shape: dim), typically initialized to a small value (e.g. 0.01)

Constructors

Link copied to clipboard
constructor(dim: Int, name: String = "LayerScale", initScale: Tensor<T, V>? = null)

Properties

Link copied to clipboard
val dim: Int
Link copied to clipboard
open override val modules: List<Module<T, V>>
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val params: List<ModuleParameter<T, V>>

Parameters owned by this node (weights, biases, etc.).

Functions

Link copied to clipboard
open override fun forward(input: Tensor<T, V>, ctx: ExecutionContext): Tensor<T, V>