layers

package
v0.0.0-...-64cb8c3 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Data            = "Data"
	Convolution     = "Convolution"
	InnerProduct    = "InnerProduct"
	Pooling         = "Pooling"
	ReLU            = "ReLU"
	Dropout         = "Dropout"
	SoftmaxWithLoss = "SoftmaxWithLoss"
	Softmax         = "Softmax"
	Lrn             = "Lrn"
)

Variables

This section is empty.

Functions

func ConvertMat64

func ConvertMat64(m mat.Matrix) [][]float32

ConvertMat64 converts mat64 matrix to [][]float32

func ConvertMatrix

func ConvertMatrix(m [][]float32) *mat.Dense

ConvertMatrix converts slice of vector to mat64.Matrix

func Im2Col

func Im2Col(img [][][]float32, kernelSize, stride int) [][]float32

Im2Col converts image 3D tensor to matrix.

Types

type BaseLayer

type BaseLayer struct {
	Name string
	Type string
}

BaseLayer is base struct of Layers.

func NewBaseLayer

func NewBaseLayer(name, t string) *BaseLayer

NewBaseLayer is constructor.

func (*BaseLayer) Forward

func (b *BaseLayer) Forward(input [][][]float32) ([][][]float32, error)

Forward is base function of Forward.

func (*BaseLayer) GetName

func (b *BaseLayer) GetName() string

GetName is method to return name of the layer.

func (*BaseLayer) GetType

func (b *BaseLayer) GetType() string

GetType is method to return type of the layer.

type ConvolutionLayer

type ConvolutionLayer struct {
	*BaseLayer
	NInput     uint32
	NOutput    uint32
	KernelSize int
	Stride     int
	Padding    int
	Weights    [][][][]float32
	Bias       []float32
	BiasTerm   bool
}

ConvolutionLayer is layer of Convolution.

func NewConvolutionLayer

func NewConvolutionLayer(name, t string, nInput, nOutput uint32, kernelSize, stride, padding int, biasTerm bool) *ConvolutionLayer

NewConvolutionLayer is constructor.

func (*ConvolutionLayer) Forward

func (conv *ConvolutionLayer) Forward(input [][][]float32) ([][][]float32, error)

Forward forwards a step.

type DropoutLayer

type DropoutLayer struct {
	*BaseLayer
	Ratio float32
}

DropoutLayer is layer of Dropout.

func NewDropoutLayer

func NewDropoutLayer(name, t string, ratio float32) *DropoutLayer

NewDropoutLayer is constructor.

func (*DropoutLayer) Forward

func (d *DropoutLayer) Forward(input [][][]float32) ([][][]float32, error)

Forward fowards a step.

type FullconnectLayer

type FullconnectLayer struct {
	*BaseLayer
	Width    int
	Height   int
	Weights  [][]float32
	BiasTerm bool
	Bias     []float32
}

FullconnectLayer is a layer.

func NewFullconnectLayer

func NewFullconnectLayer(name, t string, width, height int, biasTerm bool) *FullconnectLayer

NewFullconnectLayer is constructor.

func (*FullconnectLayer) Forward

func (f *FullconnectLayer) Forward(input [][][]float32) ([][][]float32, error)

Forward forawards a step.

type LRN

type LRN struct {
	*BaseLayer
	N     int
	K     float64
	Alpha float64
	Beta  float64
}

LRN is Local Response Normalization.

func NewLRNLayer

func NewLRNLayer(name, t string, n int, k, alpha, beta float64) *LRN

NewLRNLayer is constructor.

func (*LRN) Forward

func (lrn *LRN) Forward(input [][][]float32) ([][][]float32, error)

Forward forwards one step of the network.

type Layer

type Layer interface {
	GetName() string
	GetType() string
	Forward([][][]float32) ([][][]float32, error)
}

Layer is object of network layer.

type PoolingLayer

type PoolingLayer struct {
	*BaseLayer
	KernelSize int
	Stride     int
	Padding    int
}

PoolingLayer is layer of Pooling.

func NewPoolingLayer

func NewPoolingLayer(name, t string, kernelSize, stride, padding int) *PoolingLayer

NewPoolingLayer is constructor.

func (*PoolingLayer) Forward

func (pool *PoolingLayer) Forward(input [][][]float32) ([][][]float32, error)

Forward fowards a step.

type ReLULayer

type ReLULayer struct {
	*BaseLayer
	Slope float32
}

ReLULayer is layer of ReLU.

func NewReLULayer

func NewReLULayer(name, t string, slope float32) *ReLULayer

NewReLULayer is constructor.

func (*ReLULayer) Forward

func (r *ReLULayer) Forward(input [][][]float32) ([][][]float32, error)

Forward forwards a step.

type SoftmaxLossLayer

type SoftmaxLossLayer struct {
	*BaseLayer
}

SoftmaxLossLayer is layer of Softmax loss.

func NewSoftmaxLossLayer

func NewSoftmaxLossLayer(name, t string) *SoftmaxLossLayer

NewSoftmaxLossLayer is constructor.

func (*SoftmaxLossLayer) Forward

func (s *SoftmaxLossLayer) Forward(input [][][]float32) ([][][]float32, error)

Forward forwards a step.

Jump to

Keyboard shortcuts

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