lin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package lin implements basic linear algebra operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DotProduct

func DotProduct(a, b Vector) float32

DotProduct returns the value of the dot product for two vectors.

func Sigmoid

func Sigmoid(x float32) float32

Sigmoid applies the sigmoid function to the given value.

1 / ( 1 + e^x )

func SigmoidDerivative

func SigmoidDerivative(x float32) float32

SigmoidDerivative applies the derivative of the sigmoid function to the given value.

sigmoid(x) * 1 - sigmoid(x)

Types

type Frame

type Frame []Vector

Frame is a 2D metrix for use in linear algebra.

func (Frame) Apply

func (f Frame) Apply(fn func(float32) float32)

Apply takes the specified function and applies it to each element in the Frame, modifying it in-place.

func (Frame) DeepCopy

func (f Frame) DeepCopy() Frame

DeepCopy creates a copy of the Frame with no shared memory from the original.

func (Frame) ForEach

func (f Frame) ForEach(fn func(float32))

ForEach runs the specified function against element in the Frame.

func (Frame) ForEachPairwise

func (f Frame) ForEachPairwise(o Frame, fn func(float32, float32))

ForEachPairwise runs the specified function against each pair of elements in the two frames.

func (Frame) Pairwise

func (f Frame) Pairwise(o Frame, fn func(float32, float32) float32) Frame

Pairwise creates a new frame based on the result of running the specified function against each pair of matching elements from within the two frames.

type Vector

type Vector []float32

Vector is a 1D array of values for use in linear algebra computations.

func (Vector) MaxVal

func (v Vector) MaxVal() int

MaxVal returns the index of the maximum value within the Vector. This is useful with interpreting the output of one-hot encoding models.

Jump to

Keyboard shortcuts

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