utils

package
v0.0.0-...-98db5b7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: CC-BY-4.0 Imports: 8 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsoluteValue

func AbsoluteValue(x float32) float32

AbsoluteValue returns the absolutevalue in float32

func AddAll

func AddAll(data []float32, value float32)

AddAll adds value to all the elements in data

func CheckError

func CheckError(err error)

CheckError is a func that checks the error (right now it will panic if error but later it could check errors more thoughtfully )

func CompareInt

func CompareInt(x, y []int) bool

CompareInt compairs int32 arrays if x!=y then false else true

func CompareInt32

func CompareInt32(x, y []int32) bool

CompareInt32 compairs int32 arrays if x!=y then false else true

func CopyDimsInt32

func CopyDimsInt32(x []int32) (y []int32)

CopyDimsInt32 returns a copy of the dims.

func Dims

func Dims(args ...int32) []int32

Dims is a QOL func that can be used to organize code by renmaing it and using it in funcs all it does is just return an array of the arguements passed in it. example: slide:=utils.Dims Then when building a cnn layer you can do slide(2,2)

func DivideAll

func DivideAll(data []float32, value float32)

DivideAll will divide all the values in data by value

func ErrorWrapper

func ErrorWrapper(Comment string, err error) error

ErrorWrapper Wraps the error

func FindAvg

func FindAvg(data []float32) float32

FindAvg will find the average value of an array

func FindFittingStride

func FindFittingStride(srcdims, destdims []int32) (newsrcstrides []int32)

FindFittingStride only works if destdims[i]=n*srcdims[i] where n is an int This will give strides to srcdims so that it could kind of fit into destdims. Usually it is spaced with zeros

func FindMax

func FindMax(data []float32) float32

FindMax will return the max value of an array

func FindMaxVolExtimate

func FindMaxVolExtimate(pdims []int32, pmaxvol int32, cdims []int32) (outmaxvol int32)

FindMaxVolExtimate will return an extimated maxvol for any kind of reshape of a volume, and it will round it up to the batch size

func FindMaxVolThroughMaxBatch

func FindMaxVolThroughMaxBatch(maxbatch int32, cdims []int32) (outmaxvol int32)

FindMaxVolThroughMaxBatch through the max number of batches

func FindMin

func FindMin(data []float32) float32

FindMin will return the min value in array

func FindStridesInt

func FindStridesInt(dims []int) (strides []int)

FindStridesInt returns the strides of the dims given for an array. example if for an array of NCHW it will return [C*H*W,H*W,W,1] those can be used for traversing a 4d array

func FindStridesInt32

func FindStridesInt32(dims []int32) (strides []int32)

FindStridesInt32 returns the strides of the dims given for an array. example if for an array of NCHW it will return [C*H*W,H*W,W,1] those can be used for traversing a 4d array

func FindTotal

func FindTotal(data []float32) float32

FindTotal will return the summation of all the elements in data

func FindVolumeInt

func FindVolumeInt(dims []int) int

FindVolumeInt returns the total volume in int

func FindVolumeInt32

func FindVolumeInt32(dims, stride []int32) int32

FindVolumeInt32 returns the total volume in int32 if stride is nil it will find volume based purly on the dims

func Gaussian

func Gaussian(mean float64, std float64) float64

Gaussian returns the gaussien at zero

func Gaussian2dKernel

func Gaussian2dKernel(sigma float32, h, w int) []float32

Gaussian2dKernel will return a

func MultiplyAll

func MultiplyAll(data []float32, value float32)

MultiplyAll adds value to all the elements in data

func NormalGaussianVector

func NormalGaussianVector(length int) []float32

NormalGaussianVector randomlygenerated vector of gaussian values that are then normalized

func NormalSortedGaussianVector

func NormalSortedGaussianVector(length int) []float32

NormalSortedGaussianVector sorts randomlygenerated vector of gaussian values that are then normalized

func NumbertoString

func NumbertoString(x, outof int) string

NumbertoString will add zeros to the left of numbers. So it will file in order

func RandWeightSet

func RandWeightSet(mean, std, ninputelements float64) float64

RandWeightSet sets a randomweight based on min max values

func RandomFloat32

func RandomFloat32(floor, ceiling float32) float32

RandomFloat32 returns a random float32

func RandomFloat64

func RandomFloat64(floor, ceiling float64) float64

RandomFloat64 returns a random float64

func RandomGaussianKernelsInChannels

func RandomGaussianKernelsInChannels(h, w, c int, hwc bool) []float32

RandomGaussianKernelsInChannels makes 2d GaussianKernels that are in the channels

func RandomSigmaGaussian2dKernel

func RandomSigmaGaussian2dKernel(h, w int) []float32

RandomSigmaGaussian2dKernel returns a randomly generated Gaussian 2d Kernal

func SetAll

func SetAll(data []float32, value float32)

SetAll sets the data elements to value

func SetAllEx

func SetAllEx(sliceofvaltype interface{}, val interface{})

SetAllEx sets all the elements in sliceofvaltype to val. sliceofvaltype needs to be a slice of val. It will panic if not. Also unsupported slices will not work. It will take all 1d slices of go types. It will also take slices of half.Float16. And slices of cutil.CScalar.

func ToFLoat64Slice

func ToFLoat64Slice(input interface{}) []float64

ToFLoat64Slice takes a go slice and converts it to a []float64.

func ToFloat32Slice

func ToFloat32Slice(input interface{}) []float32

ToFloat32Slice takes a go typed slice and converts it to a []float32 slice

func ToInt32Slice

func ToInt32Slice(input interface{}) []int32

ToInt32Slice takes a go slice and convets it to a []int32. No overflow checking

func ToInt8Slice

func ToInt8Slice(input interface{}) []int8

ToInt8Slice takes a go slice and convets it to a []int8. No overflow checking

func ToUint8Slice

func ToUint8Slice(input interface{}) []uint8

ToUint8Slice takes a go slice and convets it to a []uint8. No overflow checking

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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