normalization

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package normalization provides various normalization layers for neural networks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LayerNormalization

type LayerNormalization[T tensor.Numeric] struct {
	// contains filtered or unexported fields
}

LayerNormalization implements the Layer Normalization operation.

func NewLayerNormalization

func NewLayerNormalization[T tensor.Numeric](engine compute.Engine[T], featureDim int, epsilon T) (*LayerNormalization[T], error)

NewLayerNormalization creates a new LayerNormalization layer. featureDim: The dimension over which to normalize (typically the last dimension). epsilon: A small constant to avoid division by zero.

func (*LayerNormalization[T]) Backward

func (ln *LayerNormalization[T]) Backward(ctx context.Context, dOut *tensor.Tensor[T], inputs ...*tensor.Tensor[T]) ([]*tensor.Tensor[T], error)

Backward computes the gradients for LayerNormalization.

func (*LayerNormalization[T]) Forward

func (ln *LayerNormalization[T]) Forward(ctx context.Context, inputs ...*tensor.Tensor[T]) (*tensor.Tensor[T], error)

Forward computes the Layer Normalization.

func (*LayerNormalization[T]) OutputShape

func (ln *LayerNormalization[T]) OutputShape(inputShapes ...[]int) ([]int, error)

OutputShape returns the output shape, which is the same as the input shape.

func (*LayerNormalization[T]) Parameters

func (ln *LayerNormalization[T]) Parameters() []graph.Parameter[T]

Parameters returns the trainable gamma and beta parameters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL