norm

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

README

norm

norm provides normalization of vector and tensor values. The basic functions operate on either []float32 or []float64 data, with Tensor versions using those, only for Float32 and Float64 tensors.

  • DivNorm does divisive normalization of elements
  • SubNorm does subtractive normalization of elements
  • ZScore subtracts the mean and divides by the standard deviation
  • Abs performs absolute-value on all elements (e.g., use prior to stats to produce Mean of Abs vals etc).

Documentation

Overview

Package norm provides normalization and norm metric computations e.g., L2 = sqrt of sum of squares of a vector.

DivNorm does divisive normalization of elements SubNorm does subtractive normalization of elements ZScore subtracts the mean and divides by the standard deviation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs32

func Abs32(a []float32)

Abs32 applies the Abs function to each element in given slice

func Abs64

func Abs64(a []float64)

Abs64 applies the Abs function to each element in given slice

func AbsTensor

func AbsTensor(a tensor.Tensor)

AbsTensor applies the Abs function to each element in given tensor, for float32 and float64 data types.

func AddVec64

func AddVec64(a []float64, val float64)

AddVec64 adds scalar to vector

func AddVector32

func AddVector32(a []float32, val float32)

AddVector32 adds scalar to vector

func Binarize32

func Binarize32(a []float32, thr, hiVal, loVal float32)

Binarize32 turns vector into binary-valued, by setting anything >= the threshold to the high value, and everything below to the low value.

func Binarize64

func Binarize64(a []float64, thr, hiVal, loVal float64)

Binarize64 turns vector into binary-valued, by setting anything >= the threshold to the high value, and everything below to the low value.

func DivNorm32

func DivNorm32(a []float32, nfunc Func32)

DivNorm32 does divisive normalization by given norm function i.e., it divides each element by the norm value computed from nfunc.

func DivNorm64

func DivNorm64(a []float64, nfunc Func64)

DivNorm64 does divisive normalization by given norm function i.e., it divides each element by the norm value computed from nfunc.

func FloatFunc

func FloatFunc(tsr tensor.Tensor, nfunc32 Func32, nfunc64 Func64, stIdx, nIdx int, ffunc32 func(a []float32, fun Func32), ffunc64 func(a []float64, fun Func64))

FloatFunc applies given functions to float tensor data, which is either Float32 or Float64

func FloatOnlyError

func FloatOnlyError() error

func MultVec64

func MultVec64(a []float64, val float64)

MultVec64 multiplies vector elements by scalar

func MultVector32

func MultVector32(a []float32, val float32)

MultVector32 multiplies vector elements by scalar

func SubNorm32

func SubNorm32(a []float32, nfunc Func32)

SubNorm32 does subtractive normalization by given norm function i.e., it subtracts norm computed by given function from each element.

func SubNorm64

func SubNorm64(a []float64, nfunc Func64)

SubNorm64 does subtractive normalization by given norm function i.e., it subtracts norm computed by given function from each element.

func TensorDivNorm

func TensorDivNorm(tsr tensor.Tensor, ndim int, nfunc32 Func32, nfunc64 Func64)

TensorDivNorm does divisive normalization by given norm function computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0.

func TensorSubNorm

func TensorSubNorm(tsr tensor.Tensor, ndim int, nfunc32 Func32, nfunc64 Func64)

TensorSubNorm does subtractive normalization by given norm function computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics).

func TensorUnit

func TensorUnit(tsr tensor.Tensor, ndim int)

TensorUnit subtracts the min and divides by the max, so that values are in 0-1 unit range computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics). must be a float32 or float64 tensor

func TensorZScore

func TensorZScore(tsr tensor.Tensor, ndim int)

TensorZScore subtracts the mean and divides by the standard deviation computed on the first ndim dims of the tensor, where 0 = all values, 1 = norm each of the sub-dimensions under the first outer-most dimension etc. ndim must be < NumDims() if not 0 (panics). must be a float32 or float64 tensor

func Thresh32

func Thresh32(a []float32, hi bool, hiThr float32, lo bool, loThr float32)

Thresh32 thresholds the values of the vector -- anything above the high threshold is set to the high value, and everything below the low threshold is set to the low value.

func Thresh64

func Thresh64(a []float64, hi bool, hiThr float64, lo bool, loThr float64)

Thresh64 thresholds the values of the vector -- anything above the high threshold is set to the high value, and everything below the low threshold is set to the low value.

func Unit32

func Unit32(a []float32)

Unit32 subtracts the min and divides by the max, so that values are in 0-1 unit range

func Unit64

func Unit64(a []float64)

Unit64 subtracts the min and divides by the max, so that values are in 0-1 unit range

func ZScore32

func ZScore32(a []float32)

ZScore32 subtracts the mean and divides by the standard deviation

func ZScore64

func ZScore64(a []float64)

ZScore64 subtracts the mean and divides by the standard deviation

Types

type Func32

type Func32 func(a []float32) float32

Func32 is a norm function operating on slice of float32 numbers

type Func64

type Func64 func(a []float64) float64

Func64 is a norm function operating on slices of float64 numbers

Jump to

Keyboard shortcuts

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