common

package
v0.0.0-...-be65bb2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassPredictionCorrect

func ClassPredictionCorrect(out, exp *mat64.Vector) bool

func CrossEntropyError

func CrossEntropyError(predicted, expected *mat64.Dense) float64

CrossEntropyError returns the total cross entropy error for a set of @predicted and @expected vectors. (Each row in those matrices is a vector-sample.)

func GetAbstractTimeSeries1

func GetAbstractTimeSeries1() (input, expected *mat64.Dense)

GetAbstractTimeSeries1Step creates a time-series dataset. The X sample pattern occurs twice in the dataset and predicts different things depending on the X-1 pattern. Thus a neural network needs to have at least a 1-step memory.

func GetAbstractTimeSeries2

func GetAbstractTimeSeries2() (input, expected *mat64.Dense)

GetAbstractTimeSeries2 creates a time-series dataset. The X sample pattern occurs twice in the dataset and predicts different things depending on the X-2 pattern. Thus a neural network needs to have at least a 2-step memory.

func GetAbstractTimeSeries3

func GetAbstractTimeSeries3() (input, expected *mat64.Dense)

func GetAddVec

func GetAddVec(v1, v2 *mat64.Vector) *mat64.Vector

GetAddVec wraps mat64.AddVec and returns a new vector.

func GetClassAccuracy

func GetClassAccuracy(outputs []*mat64.Vector, expected *mat64.Dense) (float64, int)

func GetDenseApply

func GetDenseApply(m *mat64.Dense, cb func(float64) float64) *mat64.Dense

GetDenseApply wraps mat64.Apply for dense matrices and returns a new vector. it slightly changes the API (see the callback signature).

func GetIris

func GetIris() (input, expected *mat64.Dense)

GetIris returns you X (samples) and Y (labels) for the Iris dataset. Labels are one-hot encoded.

func GetMaxIdx

func GetMaxIdx(v *mat64.Vector) int

func GetMulElemVec

func GetMulElemVec(v1, v2 *mat64.Vector) *mat64.Vector

GetMulElemVec wraps mat64.MulElemVec and returns a new vector.

func GetMulVec

func GetMulVec(m *mat64.Dense, v *mat64.Vector) *mat64.Vector

GetMulVec wraps mat64.MulVec and returns a new vector.

func GetOuterVec

func GetOuterVec(v1, v2 *mat64.Vector) *mat64.Dense

GetOuterVec wraps mat64.Outer and returns a new dense matrix.

func GetRandomDense

func GetRandomDense(numSamples, length int) *mat64.Dense

GetRandomDense generates @numSamples of random vectors of length @length.

func GetRandomInRange

func GetRandomInRange(min, max float64) float64

GetRandomInRange returns a random float64 in [min, max].

func GetRandomVector

func GetRandomVector(length int) *mat64.Vector

GetRandomVector generates a random vector of length @length.

func GetSubVec

func GetSubVec(v1, v2 *mat64.Vector) *mat64.Vector

GetSubVec wraps mat64.SubVec and returns a new vector.

func GetTransposed

func GetTransposed(m *mat64.Dense) *mat64.Dense

GetTransposed returns a transposed Dense matrix.

func GetVectorApply

func GetVectorApply(v *mat64.Vector, cb func(float64) float64) *mat64.Vector

GetVectorApply applies @cg to each element in @v.

func GetVectorPow

func GetVectorPow(v *mat64.Vector, power float64) *mat64.Vector

GetVectorPow raises each element in @v to @power-th power.

func GetVectorSigmoid

func GetVectorSigmoid(v *mat64.Vector) *mat64.Vector

GetVectorSigmoid applies sigmoid function to each element in @v.

func GetVectorSigmoidPrime

func GetVectorSigmoidPrime(v *mat64.Vector) *mat64.Vector

GetVectorSigmoidPrime returns derivative of VectorSigmoid.

func GetVectorSoftmax

func GetVectorSoftmax(v *mat64.Vector) *mat64.Vector

GetVectorSoftmax sets the softmax value for each element in @v.

func GetVectorSum

func GetVectorSum(v *mat64.Vector) float64

GetVectorSum returns the sum of all elements in @v.

func GetVectorTanh

func GetVectorTanh(v *mat64.Vector) *mat64.Vector

GetVectorTanh applies hyperbolic tangent to each element in @v.

func LoadFromCSV

func LoadFromCSV(path string, vectorLen int) (out *mat64.Dense)

LoadFromCSV returns a matrix restored from a file (@path) which must be a valid csv with each line representing a float64-vector of length @vectorLen.

func MaxInt

func MaxInt(a, b int) int

MaxInt returns the largest of two integers.

func PrintDense

func PrintDense(m *mat64.Dense)

PrintDense pretty prints a mat64.Dense matrix.

func PrintVector

func PrintVector(v *mat64.Vector)

PrintVector pretty prints @v and adds a newline.

func PrintVectorStrip

func PrintVectorStrip(v *mat64.Vector)

PrintVectorStrip pretty prints @v.

func PrintVectorStripSub

func PrintVectorStripSub(v *mat64.Vector, val float64, sub string)

PrintVectorStripSub is a stupid function that substitutes each component of @v that is equal to @val with @sub. This is used mostly for better visualizing time-series patterns.

func RandomDense

func RandomDense(min, max float64, m *mat64.Dense)

RandomDense fills each cell of a matrix with random numbers in [min, max].

func RandomVector

func RandomVector(min, max float64, v *mat64.Vector)

RandomVector fills each component of a vector with random numbers in [min, max].

func SampleCrossEntropyError

func SampleCrossEntropyError(predicted, expected *mat64.Vector) float64

SampleCrossEntropyError calculates the error for a sample given a @predicted and @expected vector. If the prediction for a sample is [0.3, 0.3, 0.4] and the expected output is [.0, .0, 1.], then the cross entropy error is calculated as -( (ln(0.3)*0) + (ln(0.3)*0) + (ln(0.4)*1) ) = -ln(0.4).

Types

This section is empty.

Jump to

Keyboard shortcuts

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