layers

package
v0.0.0-...-d1a4c5a Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package layers provide various layers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConvLayer

type ConvLayer struct {
	InputSize  int
	InputDepth int
	NumFilters int
	KernelSize int
	OutputSize int
	Stride     int
	Biases     []float32
	Kernels    [][][][]float32
	Input      [][][]float32
	Output     [][][]float32
}

ConvLayer represents a convolutional layer in the CNN

func NewConvLayer

func NewConvLayer(inputSize, inputDepth, numFilters, kernelSize, stride int) *ConvLayer

NewConvLayer creates a new ConvLayer object with the specified parameters

func (*ConvLayer) BackPropagate

func (cl *ConvLayer) BackPropagate(error [][][]float32) [][][]float32

BackPropagate performs backpropagation through the ConvLayer

func (*ConvLayer) ForwardPropagate

func (cl *ConvLayer) ForwardPropagate(input [][][]float32) [][][]float32

ForwardPropagate performs forward propagation through the ConvLayer

func (*ConvLayer) GetOutput

func (cl *ConvLayer) GetOutput(index int) float32

GetOutput returns the output value at the specified index

type FullyConnectedLayer

type FullyConnectedLayer struct {
	InputSize  int
	InputWidth int
	InputDepth int
	OutputSize int
	Weights    [][]float32
	Biases     []float32
	Input      []float32
	Output     []float32
}

FullyConnectedLayer represents a fully connected layer in the CNN

func NewFullyConnectedLayer

func NewFullyConnectedLayer(inputWidth, inputDepth, outputSize int) *FullyConnectedLayer

NewFullyConnectedLayer creates a new FullyConnectedLayer object with the specified parameters

func (*FullyConnectedLayer) BackPropagate

func (fcl *FullyConnectedLayer) BackPropagate(matrixError [][][]float32) [][][]float32

BackPropagate performs backpropagation through the FullyConnectedLayer

func (*FullyConnectedLayer) ForwardPropagate

func (fcl *FullyConnectedLayer) ForwardPropagate(matrixInput [][][]float32) [][][]float32

ForwardPropagate performs forward propagation through the FullyConnectedLayer

func (*FullyConnectedLayer) GetOutput

func (fcl *FullyConnectedLayer) GetOutput(index int) float32

GetOutput returns the output value at the specified index

type MaxPoolingLayer

type MaxPoolingLayer struct {
	InputSize    int
	InputDepth   int
	PoolSize     int
	OutputSize   int
	Stride       int
	Output       [][][]float32
	HighestIndex [][][][]int   // Tuple (x,y,z)[2]int representing the position of the highest value // TODO: WTF
	PrevError    [][][]float32 // Add this line

}

MaxPoolingLayer represents a max pooling layer in the CNN

func NewMaxPoolingLayer

func NewMaxPoolingLayer(inputSize, inputDepth, poolSize, stride int) *MaxPoolingLayer

NewMaxPoolingLayer creates a new custom MaxPooling layer. inputSize is the spatial dimensions (width and height) of the input. inputDepth is the number of channels or feature maps in the input data poolSize is the spatial dimensions (width and height) of the pooling window used. stride is the step size or interval at which the pooling window moves over the input. It returns an initialized MaxPoolingLayer object

func (*MaxPoolingLayer) BackPropagate

func (mpl *MaxPoolingLayer) BackPropagate(error [][][]float32) [][][]float32

BackPropagate back propagates the error in a max pooling layer. Takes in the error matrix and returns the previous error matrix

func (*MaxPoolingLayer) ForwardPropagate

func (mpl *MaxPoolingLayer) ForwardPropagate(input [][][]float32) [][][]float32

ForwardPropagate reduces the size of the input by using max pooling

func (*MaxPoolingLayer) GetOutput

func (mpl *MaxPoolingLayer) GetOutput(index int) float32

GetOutput returns the output value at the specified index

Jump to

Keyboard shortcuts

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