cnns

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: MIT Imports: 11 Imported by: 1

README

GoDoc Build Status Go Report Card

alt text

CNNs

CNNS (Convolutional Neural Networks) is a little package for developing simple neural networks, such as CNN (you don't say?) and MLP.

It has been made only for studying purposes. Do not use it in production!

Any PR's (new layers, learning optimizators, Excel-examples, bug-fixes) to improve this library will be appreciated.

Table of Contents

Features

  • CNN (convolutional neural network)
  • MLP (multilayer perceptron)

Installation

Installation is pretty simple:

go get github.com/LdDl/cnns

Usage

Just look into examples folder

For some people it is really hard to understand algorithms without step-by-step examples. So we provide some in xlsx-based files

Support

If you have troubles or questions please open an issue.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDimensionsAreNotEqual When matrix1.Dims() != matrix2.Dims()
	ErrDimensionsAreNotEqual = fmt.Errorf("Dimensions are not equal")
	// ErrNoLayers When array of layers has size 0
	ErrNoLayers = fmt.Errorf("No layers in network")
)

Functions

func ActivationArcTan

func ActivationArcTan(v float64) float64

ActivationArcTan is arctan function

See the reference: http://www.wolframalpha.com/input/?i=atan(x)

func ActivationArcTanDerivative

func ActivationArcTanDerivative(v float64) float64

ActivationArcTanDerivative is derivative of arctan

See the reference: http://www.wolframalpha.com/input/?i=(atan(x))%27

func ActivationGaussian

func ActivationGaussian(v float64) float64

ActivationGaussian is gaussian function

See the reference: http://www.wolframalpha.com/input/?i=exp(-(x%5E2))

func ActivationGaussianDerivative

func ActivationGaussianDerivative(v float64) float64

ActivationGaussianDerivative is derivative of gaussian

See the reference: http://www.wolframalpha.com/input/?i=(exp(-(x%5E2)))%27

func ActivationSoftPlus

func ActivationSoftPlus(v float64) float64

ActivationSoftPlus is logarithmic function (ln(1+exp(x))). This is integrated sigmoid actually.

See the reference: http://www.wolframalpha.com/input/?i=ln(1%2Bexp(x))
				or http://www.wolframalpha.com/input/?i=integrate(1%2F(1%2B+exp(-x)))

func ActivationSoftPlusDerivative

func ActivationSoftPlusDerivative(v float64) float64

ActivationSoftPlusDerivative is derivative of logarithm ln(1+exp(x)). This is sigmoid actually.

See the reference: http://www.wolframalpha.com/input/?i=(ln(1%2Bexp(x)))%27

func ActivationSygmoid

func ActivationSygmoid(v float64) float64

ActivationSygmoid is sigmoid function

See the reference: http://www.wolframalpha.com/input/?i=1%2F(1%2B+exp(-x))

func ActivationSygmoidDerivative

func ActivationSygmoidDerivative(v float64) float64

ActivationSygmoidDerivative is derivative of sigmoid

See the reference: http://www.wolframalpha.com/input/?i=(1%2F(1%2B+exp(-x)))%27

func ActivationTanh

func ActivationTanh(v float64) float64

ActivationTanh is hyperbolic tangent

See the reference: http://www.wolframalpha.com/input/?i=tanh(x)

func ActivationTanhDerivative

func ActivationTanhDerivative(v float64) float64

ActivationTanhDerivative is derivative of hyperbolic tangent

See the reference: http://www.wolframalpha.com/input/?i=(tanh(x))%27

func ContoursPadding

func ContoursPadding(matrix *mat.Dense, num int) *mat.Dense

ContoursPadding Apply edge padding to source matrix

matrix - source matrix
num - number of columns to add and fill with edge values

func Convolve2D

func Convolve2D(matrix, kernel *mat.Dense, channels, stride int) (*mat.Dense, error)

Convolve2D Convolution between a kernel and a matrix. See ref. https://en.wikipedia.org/wiki/Kernel_(image_processing)#Convolution

matrix - source matrix
kernel - kernel itself
channels - number of input channels
stride - step

func ExtractChannel

func ExtractChannel(matrix *mat.Dense, rows, cols, channels, channel int) *mat.Dense

ExtractChannel Returns selected channel from N-channeled matrix (usefully in terms of image processing)

matrix - Source matrix
rows - Number of rows (height)
cols - Number of columns (width)
channels - Number of channels
channel - Index of channel

func Flatten

func Flatten(matrix *mat.Dense) *mat.Dense

Flatten Convert matrix to vector. Result is defined as NewDense(1, num of rows * num of cols, matrix data)

matrix - source matrix

func Im2Col

func Im2Col(matrix *mat.Dense, kernelRows, kernelCols, stride int) *mat.Dense

Im2Col Convert image to column-based vector. See ref. http://cs231n.stanford.edu/slides/2016/winter1516_lecture11.pdf -> Slide "Implementing Convolutions: im2col"

matrix - source matrix
kernelRows - kernel's height
kernelCols - kernel's width
stride - step

func Pool2D

func Pool2D(matrix *mat.Dense, outRows, outCols, channels, windowSize, stride int, ptype poolingType, returnMasks bool) (*mat.Dense, *mat.Dense, [][][2]int)

Pool2D Pooling of matrix with defined window: windowSize/stride/pooling_type. See ref. https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer

matrix - source matrix
outRows - number of output rows
outCols - number of output columns
channels - number of input channels
windowsSize - size of "kernel"
stride - step
ptype - type of pooling (max/min/avg)
returnMasks - return masks ??? (for training mode)

func Reshape

func Reshape(matrix *mat.Dense, r, c int) (*mat.Dense, error)

Reshape Reshape matrix to given r - rows(height) and c - cols(width)

Product of target dimensions should be equal to product of source dimensions

func Rot2D180

func Rot2D180(matrix *mat.Dense) *mat.Dense

Rot2D180 Rotate matrix (2d component) by 180 degrees.

matrix - source matrix

func Rot2D270

func Rot2D270(matrix *mat.Dense) *mat.Dense

Rot2D270 Rotate matrix (2d component) by 270 degrees.

matrix - source matrix

func Rot2D90

func Rot2D90(matrix *mat.Dense, times ...int) *mat.Dense

Rot2D90 Rotate tensor (2d component) by 90 degrees.

matrix - source matrix
times - [optional] number of times to rotate matrix by 90 degrees

func ZeroPadding

func ZeroPadding(matrix *mat.Dense, num int) *mat.Dense

ZeroPadding Apply zero padding to source matrix

matrix - source matrix
num - number of columns to add and fill with zeroes

Types

type ConvLayer

type ConvLayer struct {
	Oj                        *mat.Dense
	Ok                        *mat.Dense
	Kernels                   []*mat.Dense
	PreviousDeltaKernelsState []*mat.Dense

	LocalDeltas        []*mat.Dense
	NextDeltaWeightSum *mat.Dense

	Stride     int
	KernelSize int

	OutputSize *tensor.TDsize
	// contains filtered or unexported fields
}

ConvLayer Convolutional layer structure

Oj - O{j}, activated output from previous layer for j-th neuron (in other words: previous summation input)
Ok - O{k}, activated output from current layer for k-th node (in other words: activated summation input)
SumInput - non-activated output for current layer for k-th node (in other words: summation input)

func (*ConvLayer) CalculateGradients

func (conv *ConvLayer) CalculateGradients(lossGradients *mat.Dense) error

CalculateGradients Evaluate convolutional layer's gradients

func (*ConvLayer) FeedForward

func (conv *ConvLayer) FeedForward(input *mat.Dense) error

FeedForward Feed data to convolutional layer

func (*ConvLayer) GetActivatedOutput

func (conv *ConvLayer) GetActivatedOutput() *mat.Dense

GetActivatedOutput Returns convolutional layer's output

func (*ConvLayer) GetGradients

func (conv *ConvLayer) GetGradients() *mat.Dense

GetGradients Returns convolutional layer's gradients dense

func (*ConvLayer) GetInputSize

func (conv *ConvLayer) GetInputSize() *tensor.TDsize

GetInputSize Returns dimensions of incoming data for convolutional layer

func (*ConvLayer) GetOutputSize

func (conv *ConvLayer) GetOutputSize() *tensor.TDsize

GetOutputSize Returns output size (dimensions) of convolutional layer

func (*ConvLayer) GetStride

func (conv *ConvLayer) GetStride() int

GetStride Returns stride of layer

func (*ConvLayer) GetType

func (conv *ConvLayer) GetType() string

GetType Returns "conv" as layer's type

func (*ConvLayer) GetWeights

func (conv *ConvLayer) GetWeights() []*mat.Dense

GetWeights Returns convolutional layer's weights.

func (*ConvLayer) PrintOutput

func (conv *ConvLayer) PrintOutput()

PrintOutput Pretty print convolutional layer's output

func (*ConvLayer) PrintWeights

func (conv *ConvLayer) PrintWeights()

PrintWeights Pretty print convolutional layer's weights

func (*ConvLayer) SetActivationDerivativeFunc

func (conv *ConvLayer) SetActivationDerivativeFunc(f func(v float64) float64)

SetActivationDerivativeFunc Set derivative of activation function

func (*ConvLayer) SetActivationFunc

func (conv *ConvLayer) SetActivationFunc(f func(v float64) float64)

SetActivationFunc Set activation function for layer

func (*ConvLayer) SetCustomWeights

func (conv *ConvLayer) SetCustomWeights(kernels []*mat.Dense)

SetCustomWeights Set user's weights for convolutional layer (make it carefully)

kernels - slice of kernels

func (*ConvLayer) UpdateWeights

func (conv *ConvLayer) UpdateWeights(lp *LearningParams)

UpdateWeights Update convolutional layer's weights

type FullyConnectedLayer

type FullyConnectedLayer struct {
	Oj                   *mat.Dense
	Ok                   *mat.Dense
	NextDeltaWeightSum   *mat.Dense
	Weights              *mat.Dense
	PreviousWeightsState *mat.Dense
	LocalDelta           *mat.Dense
	SumInput             *mat.Dense
	ActivationFunc       func(v float64) float64
	ActivationDerivative func(v float64) float64
	OutputSize           *tensor.TDsize
	// contains filtered or unexported fields
}

FullyConnectedLayer FC is simple layer structure (so this layer can be used for simple neural networks like XOR problem)

Oj - O{j}, activated output from previous layer for j-th neuron (in other words: previous summation input)
Ok - O{k}, activated output from current layer for k-th node (in other words: activated summation input)
SumInput - non-activated output for current layer for k-th node (in other words: summation input)
LocalDelta - δ{k}, delta for current layer for k-th neuron
NextDeltaWeightSum - SUM(δ{k}*w{j,k}), summation component for evaluating δ{j} for previous layer for j-th neuron
Weights - w{j,k}, weight from j-th node of previous layer to k-th node of current layer

func (*FullyConnectedLayer) CalculateGradients

func (fc *FullyConnectedLayer) CalculateGradients(errorsDense *mat.Dense) error

CalculateGradients Evaluate fully-connected layer's gradients

func (*FullyConnectedLayer) FeedForward

func (fc *FullyConnectedLayer) FeedForward(input *mat.Dense) error

FeedForward Feed data to fully-connected layer

func (*FullyConnectedLayer) GetActivatedOutput

func (fc *FullyConnectedLayer) GetActivatedOutput() *mat.Dense

GetActivatedOutput Returns fully-connected layer's output

func (*FullyConnectedLayer) GetGradients

func (fc *FullyConnectedLayer) GetGradients() *mat.Dense

GetGradients Returns fully-connected layer's gradients dense

func (*FullyConnectedLayer) GetInputSize

func (fc *FullyConnectedLayer) GetInputSize() *tensor.TDsize

GetInputSize Returns dimensions of incoming data for fully-connected layer

func (*FullyConnectedLayer) GetOutputSize

func (fc *FullyConnectedLayer) GetOutputSize() *tensor.TDsize

GetOutputSize Returns output size (dimensions) of fully-connected layer

func (*FullyConnectedLayer) GetStride

func (fc *FullyConnectedLayer) GetStride() int

GetStride Returns stride of fully-connected layer

func (*FullyConnectedLayer) GetType

func (fc *FullyConnectedLayer) GetType() string

GetType Returns "fc" as layer's type

func (*FullyConnectedLayer) GetWeights

func (fc *FullyConnectedLayer) GetWeights() []*mat.Dense

GetWeights Returns fully-connected layer's weights.

func (*FullyConnectedLayer) PrintOutput

func (fc *FullyConnectedLayer) PrintOutput()

PrintOutput Pretty prrint fully-connected layer's output

func (*FullyConnectedLayer) PrintWeights

func (fc *FullyConnectedLayer) PrintWeights()

PrintWeights Pretty print fully-connected layer's weights

func (*FullyConnectedLayer) SetActivationDerivativeFunc

func (fc *FullyConnectedLayer) SetActivationDerivativeFunc(f func(v float64) float64)

SetActivationDerivativeFunc Set derivative of activation function for fully-connected layer. You need to specify function: func(v float64) float64

func (*FullyConnectedLayer) SetActivationFunc

func (fc *FullyConnectedLayer) SetActivationFunc(f func(v float64) float64)

SetActivationFunc Set activation function for fully-connected layer. You need to specify function: func(v float64) float64

func (*FullyConnectedLayer) SetCustomWeights

func (fc *FullyConnectedLayer) SetCustomWeights(weights []*mat.Dense)

SetCustomWeights Set user's weights for fully-connected layer (make it carefully)

func (*FullyConnectedLayer) UpdateWeights

func (fc *FullyConnectedLayer) UpdateWeights(lp *LearningParams)

UpdateWeights Update fully-connected layer's weights

type Layer

type Layer interface {
	// GetInputSize Returns dimensions of incoming data for layer
	GetInputSize() *tensor.TDsize

	// GetOutputSize Returns output size (dimensions) of layer
	GetOutputSize() *tensor.TDsize

	// GetActivatedOutput Returns activated layer's output
	GetActivatedOutput() *mat.Dense

	// GetWeights Returns layer's weights
	GetWeights() []*mat.Dense

	// GetGradients Returns layer's gradients dense
	GetGradients() *mat.Dense

	// FeedForward Feed data to layer
	FeedForward(input *mat.Dense) error

	// CalculateGradients Evaluate layers' gradients
	CalculateGradients(errorsDense *mat.Dense) error

	// UpdateWeights Call updating process for layer's weights
	UpdateWeights(lp *LearningParams)

	// PrintOutput Pretty print layer's output
	PrintOutput()

	// PrintWeights Pretty print layer's weights
	PrintWeights()

	// GetStride Returns stride of layer
	GetStride() int

	// GetType Returns type of layer in string representation
	GetType() string

	// SetActivationFunc Set activation function
	SetActivationFunc(f func(v float64) float64)

	// SetActivationDerivativeFunc Set derivative of activation function (for backpropagation)
	SetActivationDerivativeFunc(f func(v float64) float64)

	// SetCustomWeights Set provided data as layer's weights
	SetCustomWeights(weights []*mat.Dense)
}

Layer Interface for all layer types

func NewConvLayer

func NewConvLayer(inSize *tensor.TDsize, stride, kernelSize, numberFilters int) Layer

NewConvLayer Constructor for convolutional layer. You need to specify striding step, size (square) of kernel, amount of kernels, input size.

inSize - size of input (width/height and number of channels)
stride - step on convolve operation
kernelSize - width==height of kernel
numberFilters - number of kernels

func NewFullyConnectedLayer

func NewFullyConnectedLayer(inSize *tensor.TDsize, outSize int) Layer

NewFullyConnectedLayer Constructor for fully-connected layer. You need to specify input size and output size

func NewPoolingLayer

func NewPoolingLayer(inSize *tensor.TDsize, stride, extendFilter int, poolingType string, zeroPad string) Layer

NewPoolingLayer Constructor for pooling layer.

func NewReLULayer

func NewReLULayer(inSize *tensor.TDsize) Layer

NewReLULayer - Constructor for new ReLU layer. You need to specify input size

inSize - input layer's size

type LayerParamsJSON

type LayerParamsJSON struct {
	Stride          int    `json:"stride"`
	KernelSize      int    `json:"kernel_size"`
	PoolingType     string `json:"pooling_type"`
	ZeroPaddingType string `json:"zero_padding_type"`
}

LayerParamsJSON JSON representation of layers attributes

type LearningParams

type LearningParams struct {
	LearningRate float64 `json:"learning_rate"`
	Momentum     float64 `json:"momentum"`
}

LearningParams - Parameters for training neural network.

LearningRate - η
Momentum - α

func NewLearningParametersDefault

func NewLearningParametersDefault() *LearningParams

NewLearningParametersDefault Constructor for LearningParams

func (*LearningParams) SetEta

func (lp *LearningParams) SetEta(v float64) error

SetEta Set learning rate

func (*LearningParams) SetL2Decay

func (lp *LearningParams) SetL2Decay(v float64) error

SetL2Decay Set weight's decay

func (*LearningParams) SetMomentum

func (lp *LearningParams) SetMomentum(v float64) error

SetMomentum Set momentum

type NestedData

type NestedData struct {
	Data []float64 `json:"data"`
}

NestedData JSON representation of stored data

type NetJSON

type NetJSON struct {
	Network    *NetworkJSON    `json:"network"`
	Parameters *LearningParams `json:"parameters"`
}

NetJSON JSON representation of network structure (for import and export)

type NetLayerJSON

type NetLayerJSON struct {
	LayerType  string           `json:"layer_type"`
	InputSize  *tensor.TDsize   `json:"input_size"`
	Parameters *LayerParamsJSON `json:"parameters"`
	Weights    []*NestedData    `json:"weights"`
	// Actually "OutputSize" parameter is useful for fully-connected layer only
	// There are automatic calculation of output size for other layers' types
	OutputSize *tensor.TDsize `json:"output_size"`
}

NetLayerJSON JSON representation of layer

type NetworkJSON

type NetworkJSON struct {
	Layers []*NetLayerJSON `json:"layers"`
}

NetworkJSON JSON representation of networks' layers

type PoolingLayer

type PoolingLayer struct {
	Oj           *mat.Dense
	Ok           *mat.Dense
	Masks        *mat.Dense
	Stride       int
	ExtendFilter int

	OutputSize *tensor.TDsize

	PoolingType poolingType
	ZeroPadding zeroPaddingType
	// contains filtered or unexported fields
}

PoolingLayer Pooling layer structure

Oj - Input data
Ok - Output data
LocalDelta - Gradients

func (*PoolingLayer) CalculateGradients

func (pool *PoolingLayer) CalculateGradients(errorsDense *mat.Dense) error

CalculateGradients Evaluate pooling layer's gradients

func (*PoolingLayer) FeedForward

func (pool *PoolingLayer) FeedForward(input *mat.Dense) error

FeedForward Feed data to pooling layer

func (*PoolingLayer) GetActivatedOutput

func (pool *PoolingLayer) GetActivatedOutput() *mat.Dense

GetActivatedOutput Returns pooling layer's output

func (*PoolingLayer) GetGradients

func (pool *PoolingLayer) GetGradients() *mat.Dense

GetGradients Returns pooling layer's gradients

func (*PoolingLayer) GetInputSize

func (pool *PoolingLayer) GetInputSize() *tensor.TDsize

GetInputSize Returns dimensions of incoming data for pooling layer

func (*PoolingLayer) GetOutputSize

func (pool *PoolingLayer) GetOutputSize() *tensor.TDsize

GetOutputSize Returns output size (dimensions) of pooling layer

func (*PoolingLayer) GetStride

func (pool *PoolingLayer) GetStride() int

GetStride Returns stride of layer

func (*PoolingLayer) GetType

func (pool *PoolingLayer) GetType() string

GetType Returns "pool" as layer's type

func (*PoolingLayer) GetWeights

func (pool *PoolingLayer) GetWeights() []*mat.Dense

GetWeights Returns pooling layer's weights

func (*PoolingLayer) PrintOutput

func (pool *PoolingLayer) PrintOutput()

PrintOutput Pretty print pooling layer's output

func (*PoolingLayer) PrintWeights

func (pool *PoolingLayer) PrintWeights()

PrintWeights Just to point, that pooling layer has not gradients

func (*PoolingLayer) SetActivationDerivativeFunc

func (pool *PoolingLayer) SetActivationDerivativeFunc(f func(v float64) float64)

SetActivationDerivativeFunc Set derivative of activation function

func (*PoolingLayer) SetActivationFunc

func (pool *PoolingLayer) SetActivationFunc(f func(v float64) float64)

SetActivationFunc Set activation function for layer

func (*PoolingLayer) SetCustomWeights

func (pool *PoolingLayer) SetCustomWeights(t []*mat.Dense)

SetCustomWeights Set user's weights (make it carefully) for pooling layer

func (*PoolingLayer) UpdateWeights

func (pool *PoolingLayer) UpdateWeights(lp *LearningParams)

UpdateWeights Just to point, that pooling layer does NOT updating weights

type ReLULayer

type ReLULayer struct {
	Oj         *mat.Dense
	Ok         *mat.Dense
	LocalDelta *mat.Dense

	OutputSize *tensor.TDsize
	// contains filtered or unexported fields
}

ReLULayer Rectified Linear Unit layer (activation: max(0, x))

Oj - Input data
Ok - Output data
LocalDelta - Incoming gradients*weights (backpropagation)

func (*ReLULayer) CalculateGradients

func (relu *ReLULayer) CalculateGradients(errorsDense *mat.Dense) error

CalculateGradients Evaluate ReLU layer's gradients

func (*ReLULayer) FeedForward

func (relu *ReLULayer) FeedForward(t *mat.Dense) error

FeedForward - Feed data to ReLU layer

func (*ReLULayer) GetActivatedOutput

func (relu *ReLULayer) GetActivatedOutput() *mat.Dense

GetActivatedOutput Returns ReLU layer's output

func (*ReLULayer) GetGradients

func (relu *ReLULayer) GetGradients() *mat.Dense

GetGradients Returns ReLU layer's gradients

func (*ReLULayer) GetInputSize

func (relu *ReLULayer) GetInputSize() *tensor.TDsize

GetInputSize Returns dimensions of incoming data for ReLU layer

func (*ReLULayer) GetOutputSize

func (relu *ReLULayer) GetOutputSize() *tensor.TDsize

GetOutputSize Returns output size (dimensions) of ReLU layer

func (*ReLULayer) GetStride

func (relu *ReLULayer) GetStride() int

GetStride Returns stride of layer

func (*ReLULayer) GetType

func (relu *ReLULayer) GetType() string

GetType Returns "relu" as layer's type

func (*ReLULayer) GetWeights

func (relu *ReLULayer) GetWeights() []*mat.Dense

GetWeights Returns ReLU layer's weights

func (*ReLULayer) PrintOutput

func (relu *ReLULayer) PrintOutput()

PrintOutput Pretty print ReLU layer's output

func (*ReLULayer) PrintWeights

func (relu *ReLULayer) PrintWeights()

PrintWeights Just to point, that ReLU layer has not weights

func (*ReLULayer) SetActivationDerivativeFunc

func (relu *ReLULayer) SetActivationDerivativeFunc(f func(v float64) float64)

SetActivationDerivativeFunc Set derivative of activation function

func (*ReLULayer) SetActivationFunc

func (relu *ReLULayer) SetActivationFunc(f func(v float64) float64)

SetActivationFunc Set activation function for layer

func (*ReLULayer) SetCustomWeights

func (relu *ReLULayer) SetCustomWeights(t []*mat.Dense)

SetCustomWeights Set user's weights for ReLU layer (make it carefully)

func (*ReLULayer) UpdateWeights

func (relu *ReLULayer) UpdateWeights(lp *LearningParams)

UpdateWeights Just to point, that ReLU layer does NOT updating weights

type WholeNet

type WholeNet struct {
	Layers []Layer
	LP     *LearningParams
}

WholeNet Neural net itself (slice of layers)

func (*WholeNet) Backpropagate

func (wh *WholeNet) Backpropagate(Tk *mat.Dense) error

Backpropagate Backward pass through the net (training)

func (*WholeNet) ExportToFile

func (wh *WholeNet) ExportToFile(fname string, saveWeights bool) error

ExportToFile Save network structure and its weights to JSON file

func (*WholeNet) FeedForward

func (wh *WholeNet) FeedForward(input *mat.Dense) error

FeedForward Forward pass through the net

func (*WholeNet) GetGraphvizText

func (wh *WholeNet) GetGraphvizText() (string, error)

GetGraphvizText Returns Graphviz text-based output

func (*WholeNet) GetOutput

func (wh *WholeNet) GetOutput() *mat.Dense

GetOutput Return net's output (last layer output)

func (*WholeNet) ImportFromFile

func (wh *WholeNet) ImportFromFile(fname string, randomWeights bool) error

ImportFromFile Load network to file

fname - filename,
randomWeights:
	true: random weights for new network
	false: weights from files for using network (or continue training))

func (*WholeNet) PrintOutput

func (wh *WholeNet) PrintOutput()

PrintOutput Print net's output (last layer output)

func (*WholeNet) Train

func (n *WholeNet) Train(inputs []*mat.Dense, desired []*mat.Dense, testData []*mat.Dense, testDesired []*mat.Dense, epochsNum int) (float64, float64, error)

Train Train neural network

inputs - input data for training
desired - target outputs for input

testData - input data for doing tests
testDesired - target outputs for testing

epochsNum - number of epochs

Directories

Path Synopsis
examples
utils
im
u

Jump to

Keyboard shortcuts

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