Documentation ¶
Overview ¶
Package num contains numeric Array processing routines such as optimised matix multiplication.
Index ¶
- Variables
- func Bytes(arr ...*Array) (bytes int)
- func Prod(arr []int) int
- func Release(arr ...Buffer)
- func SameShape(xd, yd []int) bool
- type Array
- type BatchNormLayer
- type Buffer
- type ConvLayer
- type DataType
- type Device
- type Function
- func Axpy(alpha float32, x, y *Array) Function
- func Copy(src, dst *Array) Function
- func Div(epsilon float32, a, b, c *Array) Function
- func Fill(a *Array, scalar float32) Function
- func Gemm(alpha float32, mA, mB, mC *Array, aTrans, bTrans TransType, incr bool) Function
- func Gemv(alpha float32, mA, x, y *Array, aTrans TransType) Function
- func Max(a, b, c *Array) Function
- func Min(a, b, c *Array) Function
- func Mul(a, b, c *Array) Function
- func Neq(x, y, res *Array) Function
- func Onehot(x, y *Array, classes int) Function
- func QuadraticLoss(x, y, res *Array) Function
- func Read(a *Array, data interface{}) Function
- func Scale(alpha float32, x *Array) Function
- func Softmax(x, res *Array) Function
- func SoftmaxLoss(x, y, res *Array) Function
- func Sqrt(x, y *Array) Function
- func Square(x, y *Array) Function
- func Sum(a, total *Array) Function
- func Transpose(mA, mB *Array) Function
- func Unhot(x, y *Array) Function
- func Write(a *Array, data interface{}) Function
- func WriteCol(a *Array, col int, data interface{}) Function
- type Layer
- type LayerOpts
- type ParamLayer
- type Queue
- type TransType
Constants ¶
This section is empty.
Variables ¶
var ( PrintThreshold = 12 PrintEdgeitems = 4 )
Parameters for array printing
Functions ¶
Types ¶
type Array ¶
Array struct is a general n dimensional tensor similar to a numpy ndarray data is stored internally in column major order, may be either on CPU or on GPU depending on buffer type
type BatchNormLayer ¶
type BatchNormLayer interface { ParamLayer InitParams(q Queue) Stats() (runMean, runVar *Array) }
BatchNorm layer has extra parameters
func NewBatchNormLayer ¶
func NewBatchNormLayer(q Queue, opts LayerOpts, avgFactor, epsilon float64, shape []int) BatchNormLayer
Create new batch normalisation layer
type Buffer ¶
type Buffer interface { // pointer to data Data() unsafe.Pointer // size of buffer in 32 bit words Capacity() int // release frees the memory Release() }
Buffer interface type represents the underlying data for an array
type ConvLayer ¶
type ConvLayer interface { ParamLayer Algorithm() string }
Convolutional network layer type
type Device ¶
type Device interface { // Setup new worker queue NewQueue() Queue // Allocate new n dimensional array NewArray(dtype DataType, dims ...int) *Array NewArrayLike(a *Array) *Array // Allocate memory with given size in 32 bit words NewBuffer(size int) Buffer }
Device interface type
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function which may be called via the queue
func Gemm ¶
Matrix matrix multiplication: mC <- alpha*dot(mA, mB) or mC <- alpha*dot(mA, mB) + mC if incr = true
func QuadraticLoss ¶
Quadratic loss function: (x-y)**2
type Layer ¶
type Layer interface { InShape() []int OutShape() []int Fprop(q Queue, in *Array, work Buffer, trainMode bool) *Array Bprop(q Queue, grad, dsrc *Array, work [3]Buffer) *Array Output() *Array Memory() (weights, outputs, temp int) BpropData() bool Release() }
Layer interface type represents an Activation or MaxPool layer
func NewActivationLayer ¶
Create new activation layer, typ may be sigmoid, tanh or relu
func NewDropoutLayer ¶
Create new dropout layer.
type ParamLayer ¶
type ParamLayer interface { Layer BiasShape() []int FilterShape() []int SetParamData(W, B, dW, dB *Array) }
Param layer also has weights and biases
type Queue ¶
type Queue interface { Device Dev() Device // Asyncronous function call Call(args ...Function) Queue // Wait for any pending requests to complete Finish() // Shutdown the queue and release any resources Shutdown() // Enable profiling Profiling(on bool, title string) Profile() string }
A Queue processes a series of operations on a Device
type TransType ¶
type TransType int
TransType flag indicates if matrix is transposed
const ( NoTrans TransType = C.CblasNoTrans Trans TransType = C.CblasTrans )