mx

package
v0.0.0-...-5f5c69f Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DimRow    = 0
	DimColumn = 1
	DimDepth  = 2
	DimDepth3 = 3
)
View Source
const (
	VersionMajor = 1
	VersionMinor = 5
	VersionPatch = 0
)
View Source
const (
	OpVar_    capi.MxnetOp = -1
	OpInput_  capi.MxnetOp = -2
	OpScalar_ capi.MxnetOp = -4
	OpNogVar_ capi.MxnetOp = -5
	OpGroup_  capi.MxnetOp = -7
	OpRef_    capi.MxnetOp = -8
	OpOutput_ capi.MxnetOp = -9
	OpBound_  capi.MxnetOp = -10
	OpDepend_ capi.MxnetOp = -11
	OpLink_   capi.MxnetOp = -12
)
View Source
const MaxDimensionCount = 4

do not change this constant code can assume exactly this value

View Source
const Version fu.VersionType = VersionMajor*10000 + VersionMinor*100 + VersionPatch

Variables

This section is empty.

Functions

func AdamUpdate

func AdamUpdate(params, grads, mean, variance *NDArray, lr, beta1, beta2, epsilon, wd float64)

func GpuCount

func GpuCount() int

func LibVersion

func LibVersion() fu.VersionType

func Nograd

func Nograd(_hidden_nograd_)

func RandomSeed

func RandomSeed(seed int)

func SgdMomUpdate

func SgdMomUpdate(params, grads, mom *NDArray, lr, momentum, wd float64)

func SgdUpdate

func SgdUpdate(params, grads *NDArray, lr, wd float64)

Types

type ActivationType

type ActivationType int
const (
	ActivReLU ActivationType = iota
	ActivSoftReLU
	ActivSoftSign
	ActivSigmoid
	ActivTanh
)

type Context

type Context int
const (
	NullContext Context = 0
	CPU         Context = 1
	GPU         Context = 2
	GPU0        Context = 2
	GPU1        Context = 1002
)

func Gpu

func Gpu(no int) Context

func (Context) Array

func (c Context) Array(tp Dtype, d Dimension, vals ...interface{}) *NDArray

func (Context) CopyAs

func (c Context) CopyAs(a *NDArray, dtype Dtype) *NDArray

func (Context) DevNo

func (c Context) DevNo() int

func (Context) DevType

func (c Context) DevType() int

func (Context) IsGPU

func (c Context) IsGPU() bool

func (Context) RandomSeed

func (c Context) RandomSeed(seed int)

func (Context) String

func (c Context) String() string

func (Context) Upgrade

func (c Context) Upgrade() Context

type Dimension

type Dimension struct {
	Shape [MaxDimensionCount]int `yaml:"shape,flow"`
	Len   int                    `yaml:"len"`
}

Array Dimension

func Dim

func Dim(a ...int) Dimension

creates new dimension object

func DimensionFromString

func DimensionFromString(s string) (Dimension, error)

func (Dimension) Empty

func (dim Dimension) Empty() bool

func (Dimension) Good

func (dim Dimension) Good() bool

check array dimension

func (Dimension) Like

func (dim Dimension) Like(b Dimension) Dimension

func (Dimension) Push

func (dim Dimension) Push(i int) Dimension

func (Dimension) SizeOf

func (dim Dimension) SizeOf(dt Dtype) int

sizeof whole array data

func (Dimension) Skip

func (dim Dimension) Skip(n int) Dimension

func (Dimension) Slice

func (dim Dimension) Slice() []int

func (Dimension) String

func (dim Dimension) String() string

represent array dimension as string

func (Dimension) Total

func (dim Dimension) Total() int

total elements in the whole array

type Dtype

type Dtype int
const (
	Float32 Dtype = 0
	Float64 Dtype = 1
	Float16 Dtype = 2
	Uint8   Dtype = 3
	Int32   Dtype = 4
	Int8    Dtype = 5
	Int64   Dtype = 6
)

func (Dtype) Size

func (tp Dtype) Size() int

func (Dtype) String

func (tp Dtype) String() string

type Graph

type Graph struct {
	Ctx   Context
	Dtype Dtype

	Input  *NDArray // network input referencing to Params["_input"]
	Output *NDArray // referencing to Outputs["_output_output"]
	Loss   *NDArray // referencing to Outputs["_loss_loss"]
	Label  *NDArray // loss function label referencing to Params["_label"]

	Outputs  map[string]*NDArray  // referencing to executor outputs except loss
	Params   map[string]*NDArray  // network parameters
	Shapes   map[string]Dimension // predefined param shape
	Autograd map[string]bool      // if param can be trained
	Grads    map[string]*NDArray  // training gradients

	Exec         capi.ExecutorHandle
	Initializers map[string]Inite
	Initialized  bool
	// contains filtered or unexported fields
}

func Compose

func Compose(
	ctx Context,
	sym *Symbol,
	loss Loss,
	input Dimension,
	dtype Dtype) *Graph

func (*Graph) Backward

func (g *Graph) Backward()

func (*Graph) Forward

func (g *Graph) Forward(train bool)

func (*Graph) GetShapes

func (g *Graph) GetShapes(withLoss bool) map[string][]int

func (*Graph) Identity

func (g *Graph) Identity() GraphIdentity

func (*Graph) InitParam

func (g *Graph) InitParam(name string)

func (*Graph) Initialize

func (g *Graph) Initialize(seed int, inite func(*NDArray, string))

func (*Graph) LogSummary

func (g *Graph) LogSummary(withLoss bool)

func (*Graph) NextSymbolId

func (g *Graph) NextSymbolId() int

func (*Graph) PrintSummary

func (g *Graph) PrintSummary(withLoss bool)

func (*Graph) Release

func (g *Graph) Release()

func (*Graph) Summary

func (g *Graph) Summary(withLoss bool) Summary

func (*Graph) SummaryOut

func (g *Graph) SummaryOut(withLoss bool, out func(string))

func (*Graph) ToJson

func (g *Graph) ToJson(withLoss bool) []byte

type GraphIdentity

type GraphIdentity [20]byte // SHA1

func (GraphIdentity) String

func (identity GraphIdentity) String() string

type GraphJs

type GraphJs struct {
	Nodes []struct {
		Op     string
		Name   string
		Attrs  map[string]string
		Inputs []interface{}
	}
}

type Inite

type Inite interface {
	Inite(*NDArray)
}

type Loss

type Loss interface {
	// out => loss
	Loss(*Symbol) *Symbol
}

type NDArray

type NDArray struct {
	// contains filtered or unexported fields
}

func Array

func Array(tp Dtype, d Dimension) *NDArray

func (*NDArray) Cast

func (a *NDArray) Cast(dt Dtype) *NDArray

func (*NDArray) Context

func (a *NDArray) Context() Context

func (*NDArray) CopyValuesTo

func (a *NDArray) CopyValuesTo(dst interface{})

func (*NDArray) Depth

func (a *NDArray) Depth() int

func (*NDArray) Dim

func (a *NDArray) Dim() Dimension

func (*NDArray) Dtype

func (a *NDArray) Dtype() Dtype

func (*NDArray) Fill

func (a *NDArray) Fill(value float32) *NDArray

func (*NDArray) Len

func (a *NDArray) Len(d int) int

func (*NDArray) NewLikeThis

func (a *NDArray) NewLikeThis() *NDArray

func (*NDArray) Normal

func (a *NDArray) Normal(mean float32, scale float32) *NDArray

func (*NDArray) Ones

func (a *NDArray) Ones() *NDArray

func (*NDArray) Raw

func (a *NDArray) Raw() []byte

func (*NDArray) ReCopyValuesTo

func (a *NDArray) ReCopyValuesTo(dst interface{})

func (*NDArray) Release

func (a *NDArray) Release()

func (*NDArray) Reshape

func (a *NDArray) Reshape(dim Dimension) *NDArray

func (*NDArray) SetValues

func (a *NDArray) SetValues(vals ...interface{})

func (*NDArray) Size

func (a *NDArray) Size() int

func (*NDArray) String

func (a *NDArray) String() string

func (*NDArray) Uniform

func (a *NDArray) Uniform(low float32, high float32) *NDArray

func (*NDArray) Values

func (a *NDArray) Values(dtype Dtype) interface{}

func (*NDArray) ValuesF32

func (a *NDArray) ValuesF32() []float32

func (*NDArray) Xavier

func (a *NDArray) Xavier(gaussian bool, factor int, magnitude float32) *NDArray

func (*NDArray) Zeros

func (a *NDArray) Zeros() *NDArray

type Param

type Param struct {
	Data     *NDArray
	Grad     *NDArray
	Shape    Dimension
	Autograd bool
}

type Summary

type Summary []SummaryRow

func (Summary) Print

func (sry Summary) Print(out func(string))

type SummaryRow

type SummaryRow struct {
	No        int         `yaml:"no"`
	Name      string      `yaml:"name"`
	Operation string      `yaml:"op"`
	Params    int         `yaml:"params"`
	Dim       Dimension   `yaml:"dimension"`
	Args      []SummryArg `yaml:"args"`
}

type SummryArg

type SummryArg struct {
	No   int    `yaml:"no""`
	Name string `yaml:"name"`
}

type Symbol

type Symbol struct {
	Op     capi.MxnetOp             `yaml:"op"`
	Value  string                   `yaml:"value"`
	Name   string                   `yaml:"name"`
	Args   []*Symbol                `yaml:"args"`
	Init   Inite                    `yaml:"-"`
	Attr   map[capi.MxnetKey]string `yaml:"attr"`
	Dim    Dimension                `yaml:"dim"`
	Output bool                     `yaml:"output"`
}

func Abs

func Abs(a *Symbol) *Symbol

func Activation

func Activation(a *Symbol, actType ActivationType) *Symbol

func Add

func Add(lv interface{}, rv interface{}) *Symbol

func And

func And(a *Symbol, b *Symbol) *Symbol

func BatchNorm

func BatchNorm(a, gamma, beta, rmean, rvar *Symbol, mom, eps float32, useGlobalStats bool, axis ...int) *Symbol

func BcastAdd

func BcastAdd(a, b *Symbol) *Symbol

func BcastDiv

func BcastDiv(a, b *Symbol) *Symbol

func BcastMul

func BcastMul(a, b *Symbol) *Symbol

func BcastSub

func BcastSub(a, b *Symbol) *Symbol

func BlockGrad

func BlockGrad(s *Symbol) *Symbol

func Bound

func Bound(a ...*Symbol) *Symbol

func Channel

func Channel(a *Symbol, ch int) *Symbol

func Concat

func Concat(a ...*Symbol) *Symbol

func Conv

func Conv(a, weight, bias *Symbol, channels int, kernel, stride, padding Dimension, groups bool, layout string) *Symbol

func Cosh

func Cosh(a *Symbol) *Symbol

func Depend

func Depend(a ...*Symbol) *Symbol

func Div

func Div(lv interface{}, rv interface{}) *Symbol

func Dot

func Dot(lv interface{}, rv interface{}) *Symbol

func Dropout

func Dropout(a *Symbol, rate float32) *Symbol

func EQ

func EQ(a *Symbol, rv interface{}) *Symbol

func Exp

func Exp(a *Symbol) *Symbol

func Flatten

func Flatten(a *Symbol) *Symbol

func FullyConnected

func FullyConnected(a, weight, bias *Symbol, size int, flatten bool) *Symbol

func GE

func GE(a *Symbol, rv interface{}) *Symbol

func GenericOp1

func GenericOp1(op, opScalar capi.MxnetOp, l *Symbol, rv interface{}) *Symbol

func GenericOp2

func GenericOp2(op, opScalar, opScalarR capi.MxnetOp, lv interface{}, rv interface{}) *Symbol

func Greater

func Greater(a *Symbol, rv interface{}) *Symbol

func Group

func Group(a ...*Symbol) *Symbol

func HardSigmoid

func HardSigmoid(a *Symbol) *Symbol

func Input

func Input(..._hidden_input_) *Symbol

func LE

func LE(a *Symbol, rv interface{}) *Symbol

func Lesser

func Lesser(a *Symbol, rv interface{}) *Symbol
func Link(name string) *Symbol

func Log

func Log(a *Symbol) *Symbol

func LogCosh

func LogCosh(a *Symbol) *Symbol

func LogSoftmax

func LogSoftmax(a *Symbol, axis ...int) *Symbol

func MakeLoss

func MakeLoss(s *Symbol) *Symbol

func Mean

func Mean(a *Symbol, axis ...int) *Symbol

func MeanKd

func MeanKd(a *Symbol, axis ...int) *Symbol

func MeanXl

func MeanXl(a *Symbol, axis ...int) *Symbol

func Minus

func Minus(a *Symbol) *Symbol

func Mul

func Mul(lv interface{}, rv interface{}) *Symbol

func NE

func NE(a *Symbol, rv interface{}) *Symbol

func Normal

func Normal(loc, scale float32, dim ...int) *Symbol

func Not

func Not(a *Symbol) *Symbol

func Ones

func Ones(dim ...int) *Symbol

func OnesLike

func OnesLike(a *Symbol) *Symbol

func Or

func Or(a *Symbol, b *Symbol) *Symbol

func Output

func Output(a *Symbol, name string) *Symbol

func Pick

func Pick(a *Symbol, label *Symbol) *Symbol

func Pool

func Pool(a *Symbol, kernel, stride, padding Dimension, ceil bool, maxpool bool) *Symbol

func Pow

func Pow(lv interface{}, rv interface{}) *Symbol

func ReLU

func ReLU(a *Symbol) *Symbol

func Ref

func Ref(name string, a ...*Symbol) *Symbol

func Reshape

func Reshape(a *Symbol, dim ...int) *Symbol

func ReshapeLike

func ReshapeLike(a, b *Symbol) *Symbol

func Sigmoid

func Sigmoid(a *Symbol) *Symbol

func Sin

func Sin(a *Symbol) *Symbol

func Slice

func Slice(a *Symbol, axis, begin, end int) *Symbol

func Softmax

func Softmax(a *Symbol, axis ...int) *Symbol

func SoftmaxActivation

func SoftmaxActivation(a *Symbol, channel bool) *Symbol

func SoftmaxCrossEntropy

func SoftmaxCrossEntropy(a, b *Symbol, axis ...int) *Symbol

func SoftmaxOutput

func SoftmaxOutput(a *Symbol, l *Symbol, multiOutput bool) *Symbol

func Sqrt

func Sqrt(a *Symbol) *Symbol

func Square

func Square(a *Symbol) *Symbol

func Stack

func Stack(a ...*Symbol) *Symbol

func Stack1

func Stack1(a ...*Symbol) *Symbol

func Sub

func Sub(lv interface{}, rv interface{}) *Symbol

func Sum

func Sum(a *Symbol, axis ...int) *Symbol

func Sum1

func Sum1(a *Symbol) *Symbol

func SumNan

func SumNan(a *Symbol, axis ...int) *Symbol

func SumXl

func SumXl(a *Symbol, axis ...int) *Symbol

func SwapAxes

func SwapAxes(a *Symbol, x, y int) *Symbol

func SymbolCast

func SymbolCast(i interface{}) (*Symbol, error)

func Tanh

func Tanh(a *Symbol) *Symbol

func Transpose

func Transpose(a *Symbol, axis ...int) *Symbol

func Value

func Value(name string, a ...float32) *Symbol

func Var

func Var(name string, opt ...interface{}) *Symbol

func Xor

func Xor(a *Symbol, b *Symbol) *Symbol

func Zeros

func Zeros(dim ...int) *Symbol

func ZerosLike

func ZerosLike(a *Symbol) *Symbol

func (*Symbol) SetName

func (s *Symbol) SetName(name string) *Symbol

func (*Symbol) SetOutput

func (s *Symbol) SetOutput(on bool) *Symbol

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳