Documentation ¶
Overview ¶
Package cnn contains structs and methods used to do forward, and backward operations for convolution layers
Index ¶
- type Info
- type Layer
- func (c *Layer) BAvg(handle *cudnn.Handler) (float32, error)
- func (c *Layer) BMax(handle *cudnn.Handler) (float32, error)
- func (c *Layer) BMin(handle *cudnn.Handler) (float32, error)
- func (c *Layer) BNorm1(handle *cudnn.Handler) (float32, error)
- func (c *Layer) BNorm2(handle *cudnn.Handler) (float32, error)
- func (c *Layer) BackPropData(handle *cudnn.Handler, wspace *nvidia.Malloced, dx, dy *layers.Tensor) error
- func (c *Layer) BackPropFilter(handle *cudnn.Handler, wspace *nvidia.Malloced, x, dy *layers.Tensor) error
- func (c *Layer) BackPropFilterData(handle *cudnn.Handler, wspacedata, wspacefilter *nvidia.Malloced, ...) error
- func (c *Layer) Bias() *layers.Tensor
- func (c *Layer) DBAvg(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DBMax(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DBMin(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DBNorm1(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DBNorm2(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DWAvg(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DWMax(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DWMin(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DWNorm1(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DWNorm2(handle *cudnn.Handler) (float32, error)
- func (c *Layer) DeltaWeights() *layers.Tensor
- func (c *Layer) DeltaWeightsFillSlice(h *cudnn.Handler, input interface{}, length int) error
- func (c *Layer) FilterProps() (gocudnn.TensorFormat, gocudnn.DataType, []int32, error)
- func (c *Layer) FindOutputDims(input *layers.Tensor) (dims []int32, err error)
- func (c *Layer) ForwardProp(handle *cudnn.Handler, wspace *nvidia.Malloced, x, y *layers.Tensor) error
- func (c *Layer) GetBwdDataAlgoPerfList(handle *cudnn.Handler, x, y *layers.Tensor, workspace *nvidia.Malloced) ([]convolution.BackDataPerformance, error)
- func (c *Layer) GetBwdFiltAlgoPerfList(handle *cudnn.Handler, x, y *layers.Tensor, workspace *nvidia.Malloced) ([]convolution.BackFilterPerformance, error)
- func (c *Layer) GetFwdAlgoPerfList(handle *cudnn.Handler, x, y *layers.Tensor, workspace *nvidia.Malloced) ([]convolution.ForwardPerformance, error)
- func (l *Layer) Info() (Info, error)
- func (c *Layer) L1L2Loss() (L1 float32, L2 float32)
- func (c *Layer) LoadBiasValues(handle *cudnn.Handler, slice interface{}, length int) error
- func (c *Layer) LoadBiasValuesEX(handle *cudnn.Handler, r io.Reader) error
- func (c *Layer) LoadTrainer(handle *cudnn.Handler, forweights, forbias trainer.Trainer) error
- func (c *Layer) LoadWValues(handle *cudnn.Handler, slice interface{}, length int) error
- func (c *Layer) LoadWvaluesEX(handle *cudnn.Handler, r io.Reader) error
- func (c *Layer) MakeOutputTensor(handle *cudnn.Handler, input *layers.Tensor) (*layers.Tensor, error)
- func (c *Layer) MakeOutputTensorInference(handle *cudnn.Handler, input *layers.Tensor) (*layers.Tensor, error)
- func (c *Layer) MakeRandom(h *cudnn.Handler, inputdims []int32) error
- func (c *Layer) OutputDims(inputdims []int32) []int32
- func (c *Layer) SetBackwardScalars(alpha, beta float64)
- func (c *Layer) SetBestAlgosConsidering(handle *cudnn.Handler, x, y *layers.Tensor, wspacelimit int, fastest bool) (uint, error)
- func (c *Layer) SetBestAlgosConsideringDims4d(handle *cudnn.Handler, x, y, w []int32, wspacelimit int, fastest bool) (uint, error)
- func (c *Layer) SetBwdDataAlgoPerformance(bwddata convolution.BackDataPerformance)
- func (c *Layer) SetBwdFiltAlgoPerformance(bwdfilt convolution.BackFilterPerformance)
- func (c *Layer) SetForwardScalars(alpha, beta float64)
- func (c *Layer) SetFwdAlgoPerformance(fwd convolution.ForwardPerformance)
- func (c *Layer) SetMathType(mtype gocudnn.MathType) error
- func (c *Layer) SetOtherScalars(alpha, beta float64)
- func (c *Layer) String() string
- func (c *Layer) ToggleBiasPrintValueForStringer()
- func (c *Layer) ToggleDBiasPrintValueForStringer()
- func (c *Layer) ToggleDWeightsPrintValueForStringer()
- func (c *Layer) ToggleWeightsPrintValueForStringer()
- func (c *Layer) UpdateWeights(handle *cudnn.Handler, batch, epoch int) error
- func (c *Layer) WAvg(handle *cudnn.Handler) (float32, error)
- func (c *Layer) WMax(handle *cudnn.Handler) (float32, error)
- func (c *Layer) WMin(handle *cudnn.Handler) (float32, error)
- func (c *Layer) WNorm1(handle *cudnn.Handler) (float32, error)
- func (c *Layer) WNorm2(handle *cudnn.Handler) (float32, error)
- func (c *Layer) Weights() *layers.Tensor
- func (c *Layer) WeightsFillSlice(h *cudnn.Handler, input interface{}, length int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { Convolution convolution.Info `json:"convolution,omitempty"` Weights tensor.Info `json:"weights,omitempty"` Bias tensor.Info `json:"bias,omitempty"` }
Info contains the info that is needed to build a CNN layer
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
Layer is a struct that holds filter, bias and convolution descriptors. The memory for w, dw, bias, dbias. The algos for forward, backward (data, filter) and the scalars for those algos. 1
func Setup ¶
func Setup(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, mtype gocudnn.MathType, groupcount int32, filterdims []int32, convmode gocudnn.ConvolutionMode, pad, stride, dilation []int32, seed uint64) (*Layer, error)
Setup sets up the speed of the fwd and bwd algos dynamically. guessinputdims is really for setting up the random weights.
func SetupBasic ¶
func SetupBasic(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, mtype gocudnn.MathType, groupcount int32, w, dw, b, db *layers.Tensor, convmode gocudnn.ConvolutionMode, pad, stride, dilation []int32) (*Layer, error)
SetupBasic sets up a convolution layer with the memory for the gpu added to it. This can be used for layers that share the same memory, but might have different convolution properties.
func (*Layer) BackPropData ¶
func (c *Layer) BackPropData(handle *cudnn.Handler, wspace *nvidia.Malloced, dx, dy *layers.Tensor) error
BackPropData performs the BackPropData
func (*Layer) BackPropFilter ¶
func (c *Layer) BackPropFilter(handle *cudnn.Handler, wspace *nvidia.Malloced, x, dy *layers.Tensor) error
BackPropFilter does the backward propagation for the filter You will pass a handle workspace memory x,dy layer.io
func (*Layer) BackPropFilterData ¶
func (c *Layer) BackPropFilterData(handle *cudnn.Handler, wspacedata, wspacefilter *nvidia.Malloced, x, dx, dy *layers.Tensor) error
BackPropFilterData does the backprop for the data and the filter
Dx and X can be the same.
func (*Layer) DeltaWeights ¶
DeltaWeights returns the deltaweights
func (*Layer) DeltaWeightsFillSlice ¶
DeltaWeightsFillSlice will fill the weights with values
func (*Layer) FilterProps ¶
FilterProps returns the filter properties of the Convolution Layer
func (*Layer) FindOutputDims ¶
FindOutputDims finds the outputdims fo the cnn
func (*Layer) ForwardProp ¶
func (c *Layer) ForwardProp(handle *cudnn.Handler, wspace *nvidia.Malloced, x, y *layers.Tensor) error
ForwardProp performs the ForwardProp
func (*Layer) GetBwdDataAlgoPerfList ¶
func (c *Layer) GetBwdDataAlgoPerfList(handle *cudnn.Handler, x, y *layers.Tensor, workspace *nvidia.Malloced) ([]convolution.BackDataPerformance, error)
GetBwdDataAlgoPerfList gets a list of backward performance algos
func (*Layer) GetBwdFiltAlgoPerfList ¶
func (c *Layer) GetBwdFiltAlgoPerfList(handle *cudnn.Handler, x, y *layers.Tensor, workspace *nvidia.Malloced) ([]convolution.BackFilterPerformance, error)
GetBwdFiltAlgoPerfList gets a list of forward performance algos
func (*Layer) GetFwdAlgoPerfList ¶
func (c *Layer) GetFwdAlgoPerfList(handle *cudnn.Handler, x, y *layers.Tensor, workspace *nvidia.Malloced) ([]convolution.ForwardPerformance, error)
GetFwdAlgoPerfList gets a list of forward performance algos
func (*Layer) LoadBiasValues ¶
LoadBiasValues will load a slice into cuda memory for the Weights.
func (*Layer) LoadBiasValuesEX ¶
LoadBiasValuesEX takes a reader and coppies the bytes over to the bias
func (*Layer) LoadTrainer ¶
LoadTrainer sets up the momentum trainer
func (*Layer) LoadWValues ¶
LoadWValues will load a slice into cuda memory for the Weights.
func (*Layer) LoadWvaluesEX ¶
LoadWvaluesEX takes a reader and coppies the bytes over to the weights
func (*Layer) MakeOutputTensor ¶
func (c *Layer) MakeOutputTensor(handle *cudnn.Handler, input *layers.Tensor) (*layers.Tensor, error)
MakeOutputTensor makes the output tensor of the layer
func (*Layer) MakeOutputTensorInference ¶
func (c *Layer) MakeOutputTensorInference(handle *cudnn.Handler, input *layers.Tensor) (*layers.Tensor, error)
MakeOutputTensorInference makes the output tensor of the layer
func (*Layer) MakeRandom ¶
MakeRandom does what it says it will make the weights random considering the fanin
func (*Layer) OutputDims ¶
OutputDims will return the dims for the output
func (*Layer) SetBackwardScalars ¶
SetBackwardScalars sets the alpha and beta scalars, the defaults are alpha, 1, beta=0 and are initialized in the function FilterSetup
func (*Layer) SetBestAlgosConsidering ¶
func (c *Layer) SetBestAlgosConsidering(handle *cudnn.Handler, x, y *layers.Tensor, wspacelimit int, fastest bool) (uint, error)
SetBestAlgosConsidering this method will set the best algos for the fwd, bwddata, and bwdfilter algos. and return the workspace size along with an error if an error is found the function will not set any values, Here are some simple rules to the function if fastest is marked true. Then it will find the fastest algo no mater what worksize is. if fastest is set to false. It will check if wspace is greater than zero then it will set the algos to the fastest algo considering the workspace size, and return the largest wspacesize in all the algos else it will find and set the fastest algos with no workspace size and return 0
func (*Layer) SetBestAlgosConsideringDims4d ¶
func (c *Layer) SetBestAlgosConsideringDims4d(handle *cudnn.Handler, x, y, w []int32, wspacelimit int, fastest bool) (uint, error)
SetBestAlgosConsideringDims4d this method will set the best algos for the fwd, bwddata, and bwdfilter algos. and return the workspace size along with an error if an error is found the function will not set any values, Here are some simple rules to the function if fastest is marked true. Then it will find the fastest algo no mater what worksize is. if fastest is set to false. It will check if wspace is greater than zero then it will set the algos to the fastest algo considering the workspace size, and return the largest wspacesize in all the algos else it will find and set the fastest algos with no workspace size and return 0
func (*Layer) SetBwdDataAlgoPerformance ¶
func (c *Layer) SetBwdDataAlgoPerformance(bwddata convolution.BackDataPerformance)
SetBwdDataAlgoPerformance sets the Performance Values
func (*Layer) SetBwdFiltAlgoPerformance ¶
func (c *Layer) SetBwdFiltAlgoPerformance(bwdfilt convolution.BackFilterPerformance)
SetBwdFiltAlgoPerformance sets the Performance Values
func (*Layer) SetForwardScalars ¶
SetForwardScalars sets the alpha and beta scalars, the defaults are alpha, 1, beta=0 and are initialized in the function FilterSetup
func (*Layer) SetFwdAlgoPerformance ¶
func (c *Layer) SetFwdAlgoPerformance(fwd convolution.ForwardPerformance)
SetFwdAlgoPerformance sets the Performance Values
func (*Layer) SetMathType ¶
SetMathType sets the mathtype
func (*Layer) SetOtherScalars ¶
SetOtherScalars sets the alpha and beta scalars for the weights, the defaults are alpha, 1, beta=1 and are initialized in the function FilterSetup
func (*Layer) ToggleBiasPrintValueForStringer ¶
func (c *Layer) ToggleBiasPrintValueForStringer()
ToggleBiasPrintValueForStringer toggles if Bias values will be printed
func (*Layer) ToggleDBiasPrintValueForStringer ¶
func (c *Layer) ToggleDBiasPrintValueForStringer()
ToggleDBiasPrintValueForStringer toggles if dBias values will be printed
func (*Layer) ToggleDWeightsPrintValueForStringer ¶
func (c *Layer) ToggleDWeightsPrintValueForStringer()
ToggleDWeightsPrintValueForStringer toggles if DWeight values will be printed
func (*Layer) ToggleWeightsPrintValueForStringer ¶
func (c *Layer) ToggleWeightsPrintValueForStringer()
ToggleWeightsPrintValueForStringer toggles if Weight values will be printed
func (*Layer) UpdateWeights ¶
UpdateWeights does the weight update