robonet

package module
Version: v0.0.0-...-750ee74 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2018 License: GPL-3.0 Imports: 11 Imported by: 1

README

Build Status GoDoc Go Report Card codecov

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareJPEG

func CompareJPEG(path1, path2 string, threshold float64) bool

CompareJPEG compares two JPEGs pixel-wise. A threshold (0-255) is specified. 0 means the two images are identical

func CompareTIFF

func CompareTIFF(path1, path2 string, threshold float64) bool

CompareTIFF compares two TIFFs pixel-wise. A threshold (0-255) is specified. 0 means the two images are identical

func Equal3Dim

func Equal3Dim(e1, e2, e3, i1, i2, i3 int) bool

Equal3Dim checks if the size of two volumes are the same

func EqualVolDim

func EqualVolDim(v1, v2 Volume) bool

EqualVolDim checks if two given volumes have the same dimensions

func Odd3Dim

func Odd3Dim(i1, i2, i3 int) bool

Odd3Dim checks if the rows and collumns are odd

func Round

func Round(val float64, places int) (newVal float64)

Round rounds to a given number of places

func SaveVolumeToJPEG

func SaveVolumeToJPEG(path string, vol Volume)

SaveVolumeToJPEG saves a volume to a given JPEG-file

func SaveVolumeToTIFF

func SaveVolumeToTIFF(path string, vol Volume)

SaveVolumeToTIFF saves a volume to a given TIFF-file

func SigmoidFast

func SigmoidFast(x float64) float64

SigmoidFast calcultes the value for activation using a fast sigmoid approximation

func VolumeToImage

func VolumeToImage(vol Volume) image.Image

VolumeToImage converts a volume to a image. Values are rounded to 2 decimal palaces

Types

type ConvLayer

type ConvLayer struct {
	LayerFields
	// contains filtered or unexported fields
}

ConvLayer basic type for a convolutional layer The layer will compute the output of neurons that are connected to local regions in the input, each computing a dot product between their weights and a small region they are connected to in the input volume. This may result in volume such as [32x32x12] if we decided to use 12 filters.

func (*ConvLayer) AddKernel

func (l *ConvLayer) AddKernel(kern Kernel, strideR, strideC int)

AddKernel adds a kernel to a layer

func (*ConvLayer) Calculate

func (l *ConvLayer) Calculate()

Calculate applys all Kernels to a given Volume

func (ConvLayer) Kernels

func (l ConvLayer) Kernels() []Kernel

Kernels returns the kernels of the layer

type D3Volume

type D3Volume struct {
	Fields []mat64.Dense
}

D3Volume implements Volume

func New

func New(r, c, d int) *D3Volume

New generates a D3Volume of fixed size filled with zeros

func NewRand

func NewRand(r, c, d int) *D3Volume

NewRand generates a D3Volume of fixed size filled with values between 0 and 1

func NewWithData

func NewWithData(r, c, d int, data []float64) *D3Volume

NewWithData generates a D3Volume of fixed size filled with custom data

func (*D3Volume) Apply

func (vol *D3Volume) Apply(kern Kernel, strideR, strideC int)

Apply applys the given kernel to the whole volume, returnung a D3Volume with 1 depth

func (*D3Volume) Collumns

func (vol *D3Volume) Collumns() int

Collumns of the D3Volume

func (*D3Volume) Depth

func (vol *D3Volume) Depth() int

Depth of the D3Volume

func (*D3Volume) Elems

func (vol *D3Volume) Elems() int

Elems returns the number of elements in a volume

func (*D3Volume) EqualSize

func (vol *D3Volume) EqualSize(a Volume) bool

EqualSize checks if the size of two volumes are the same

func (*D3Volume) Equals

func (vol *D3Volume) Equals(in Volume) bool

Equals compares the volume to another volume

func (*D3Volume) GetAt

func (vol *D3Volume) GetAt(r, c, d int) float64

GetAt returns the element of the volume at a given position

func (D3Volume) Max

func (vol D3Volume) Max() float64

Max returns the hightest number in a volume

func (D3Volume) Min

func (vol D3Volume) Min() float64

Min returns the lowest number in a volume

func (*D3Volume) MulElem

func (vol *D3Volume) MulElem(v1 Volume)

MulElem multiplies the volume with another volume element-wise

func (*D3Volume) Norm

func (vol *D3Volume) Norm(max float64)

Norm normalizes the volume to a given maximum and 0

func (*D3Volume) PointReflect

func (vol *D3Volume) PointReflect()

PointReflect calculates the pointreflection of a volume

func (*D3Volume) Print

func (vol *D3Volume) Print()

Print prints the D3Volume to the console in a pretty format

func (*D3Volume) Reflect

func (vol *D3Volume) Reflect()

Reflect calculates the reflectio of a volume (left-right)

func (*D3Volume) Rows

func (vol *D3Volume) Rows() int

Rows of the D3Volume

func (*D3Volume) SetAll

func (vol *D3Volume) SetAll(v Volume)

SetAll sets all values of the volume from another equal-sized volume

func (*D3Volume) SetAt

func (vol *D3Volume) SetAt(r, c, d int, val float64)

SetAt sets the element of a volume at a given position

func (*D3Volume) Shape

func (vol *D3Volume) Shape() (int, int, int)

Shape returns the extend in every dimension of a D3Volume

func (*D3Volume) SimilarTo

func (vol *D3Volume) SimilarTo(in Volume, threshold float64) bool

SimilarTo compares two volumes with a given threshold

func (*D3Volume) SubVolume

func (vol *D3Volume) SubVolume(tR, tC, r, c int) Volume

SubVolume returns a part of the original D3Volume. tR and tC determine the center of copying, r and c the size of the subvolume. If the size exceeds the underlying volume the an error will be thrown, padding is not allowed.

func (D3Volume) SubVolumePadded

func (vol D3Volume) SubVolumePadded(cR, cC, r, c int) Volume

SubVolumePadded returns a part of the original D3Volume. cR and cC determine the center of copying, r and c the size of the subvolume. If the size exceeds the underlying volume the submodule is filled(padded with Zeros.

type FCLayer

type FCLayer struct {
	LayerFields
}

FCLayer (i.e. fully-connected) layer will compute the class scores, resulting in volume of size [1x1x10], where each of the 10 numbers correspond to a class score, such as among the 10 categories of CIFAR-10. As with ordinary Neural Networks and as the name implies, each neuron in this layer will be connected to all the numbers in the previous volume.

func (*FCLayer) Calculate

func (lay *FCLayer) Calculate()

Calculate method for fully connected layers

type InputLayer

type InputLayer struct {
	LayerFields
}

InputLayer [32x32x3] will hold the raw pixel values of the image, in this case an image of width 32, height 32, and with three color channels R,G,B.

func (*InputLayer) Calculate

func (lay *InputLayer) Calculate()

Calculate method fir inputlaters, sets the ouput to input

type Kernel

type Kernel struct {
	Volume
}

Kernel represets a basic conv kernel

func NewKernel

func NewKernel(r, c, d int) Kernel

NewKernel creates a new kernel initialized with zeros

func NewKernelFilled

func NewKernelFilled(r, c, d int, fil float64) Kernel

NewKernelFilled creates a new kernel initialized with random values

func NewKernelRandom

func NewKernelRandom(r, c, d int) Kernel

NewKernelRandom creates a new kernel initialized with random values

func (Kernel) Apply

func (kern Kernel) Apply(in Volume) float64

Apply applys the kernel to a equally sized chunk of a volume Only kernels of the same size as the volume can be applied

func (Kernel) Elems

func (kern Kernel) Elems() int

Elems returns the number of element a kernel has

func (*Kernel) Equals

func (kern *Kernel) Equals(in Kernel) bool

Equals compares to kernels

func (Kernel) Sum

func (kern Kernel) Sum() float64

Sum returns the sum of all elements in the kernel

type Layer

type Layer interface {
	Input(Volume)
	Calculate()
	Output() Volume
}

Layer interface

type LayerFields

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

LayerFields basic data fields every layertype should have

func (*LayerFields) Input

func (lf *LayerFields) Input(vol Volume)

Input is the Default method for Setting the input of a layer

func (*LayerFields) Output

func (lf *LayerFields) Output() Volume

Output is the default method for retrieving the output of a layer

type Net

type Net struct {
	Input  Volume
	Output Volume
	// contains filtered or unexported fields
}

Net is the basic type for Conv nets

func (*Net) AddLayer

func (net *Net) AddLayer(lay Layer)

AddLayer adds another layer to the net

func (*Net) Calculate

func (net *Net) Calculate()

Calculate calcuates te Output

type NormLayer

type NormLayer struct {
	LayerFields
	NormVal float64
}

NormLayer is a normalisation layer

func (*NormLayer) Calculate

func (lay *NormLayer) Calculate()

Calculate applyes the normalisation funktion for every element in the input volume

type PoolLayer

type PoolLayer struct {
	LayerFields
	SizeR   int
	SizeC   int
	StrideR int
	StrideC int
}

PoolLayer will perform a downsampling operation along the spatial dimensions (width, height), resulting in volume such as [16x16x12].

func (*PoolLayer) Calculate

func (lay *PoolLayer) Calculate()

Calculate for Pooling layers applies the pooling operation after the parameters have been set.

type ReluLayer

type ReluLayer struct {
	LayerFields
}

ReluLayer will apply an elementwise activation function, such as the max(0,x)max(0,x) thresholding at zero. This leaves the size of the volume unchanged ([32x32x12]).

func (*ReluLayer) Calculate

func (lay *ReluLayer) Calculate()

Calculate for ReluLayer

type Volume

type Volume interface {
	//New() Volume
	//NewFull() Volume
	//NewRand() Volume
	Apply(Kernel, int, int)
	Collumns() int
	Depth() int
	Elems() int
	EqualSize(Volume) bool
	Equals(Volume) bool
	GetAt(int, int, int) float64
	Max() float64
	Min() float64
	MulElem(Volume)
	Norm(float64)
	PointReflect()
	Print()
	Reflect()
	Rows() int
	SetAll(Volume)
	SetAt(int, int, int, float64)
	Shape() (int, int, int)
	SimilarTo(Volume, float64) bool
	SubVolume(int, int, int, int) Volume
	SubVolumePadded(int, int, int, int) Volume
}

Volume is a basic type to hold the layer's info

func ImageToVolume

func ImageToVolume(img image.Image) Volume

ImageToVolume creates a volume from a image.Image

func NewFull

func NewFull(r, c, d int, fil float64) Volume

NewFull generates a D3Volume of fixed size filled with values between 0 and 1

func VolumeFromJPEG

func VolumeFromJPEG(path string) Volume

VolumeFromJPEG creates a volume from a given file

func VolumeFromTIFF

func VolumeFromTIFF(path string) Volume

VolumeFromTIFF creates a volume from a given file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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