Documentation ¶
Overview ¶
Package nn implements a small collection of neural network layers for denoising auto-encoders.
It is designed for inference, not for training.
Index ¶
- func ConvOutputSize(height, width, kernelSize, stride int) (heightOut, widthOut int)
- func DeconvOutputSize(height, width, kernelSize, stride int) (heightOut, widthOut int)
- func Groups(t *Tensor, numGroups int, f func(groupIdx, dataIdx int))
- func Patches(t *Tensor, kernelSize, stride int, f func(int, *Tensor))
- type Bias
- type Bilateral
- type Conv
- type Deconv
- type GroupNorm
- type Layer
- type Mul
- type NN
- type Pad
- type ReLU
- type Residual
- type SpatialConv
- type Tensor
- type Unpad
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvOutputSize ¶
ConvOutputSize gets the output dimensions from a convolution operation.
func DeconvOutputSize ¶
DeconvOutputSize gets the output dimensions from a transposed convolution operation.
func Groups ¶
Groups iterates over the entries of t in order, but adds a groupIdx parameter indicating which group each component belongs to for group normalization.
func Patches ¶
Patches extracts image patches for a convolution of the given kernel size and stride, and calls f with each patch.
It may call f from multiple Goroutines concurrently.
The patches may be passed to f in any order. The index passed as the first argument to f goes left to right, top to bottom, so that patches are indexed like the pixels of an output image.
Types ¶
type Bias ¶
type Bias struct {
Data []float32
}
A Bias layer adds a per-channel constant to a Tensor.
type Conv ¶
Conv is a 2D convolution operator.
It contains weights of the shape:
[out_depth x in_depth x kernel_size x kernel_size]
type Deconv ¶
Deconv is a 2D transposed convolution operator.
It contains weights of the shape:
[in_depth x out_depth x kernel_size x kernel_size]
type GroupNorm ¶
type GroupNorm struct {
NumGroups int
}
GroupNorm implements the normalization step of group normalization.
type Mul ¶
type Mul struct {
Data []float32
}
A Mul layer multiplies a per-channel mask to a Tensor.
type Residual ¶
type Residual []Layer
Residual is a special Layer that composes multiple other Layers and adds the output to the input.
type SpatialConv ¶
SpatialConv is a spatial-only 2D convolution operator. Unlike Conv, it uses a separate depthwise filter for each channel of the input; channels are not mixed.
It contains weights of the shape:
[depth x kernel_size x kernel_size]
func (*SpatialConv) Apply ¶
func (s *SpatialConv) Apply(t *Tensor) *Tensor
Apply applies the convolution to a Tensor.
The resulting Tensor's size is determined by ConvOutputSize().
type Tensor ¶
Tensor is a 3D array of numbers.
It is arranged as [height x width x depth], with the outer dimension being height.
func NewTensorRGB ¶
NewTensorRGB creates an RGB Tensor from an image.