Documentation ¶
Overview ¶
Package tensor is used to make tensors by using gocudnn. It is currently not supporting what I call the "EX" functions. because the Tensor struct is also going to be carrying a filter descripter. Also I call it "EX" functions loosly, because I think there is a miss labeling of the function names in cudnn. Basicly it is the set tensor fuctions that don't include the format and include the strides asdf
Index ¶
- func MakeJPG(folder, subfldr string, index int, img image.Image) error
- func ToOneImage(layer [][]image.Image, X, Y int) image.Image
- type Concat
- func (c *Concat) Backward(h *cudnn.Handler, srcs []*Volume, dest *Volume) error
- func (c *Concat) Forward(h *cudnn.Handler, srcs []*Volume, dest *Volume) error
- func (c *Concat) GetOutputDimsfromInputDims(srcs [][]int32, frmt gocudnn.TensorFormat) ([]int32, error)
- func (c *Concat) GetOutputdims(srcs []*Volume) (outputdims []int32, err error)
- func (c *Concat) SetBackwardAlpha(alpha float64)
- func (c *Concat) SetBackwardBeta(beta float64)
- func (c *Concat) SetForwardAlpha(alpha float64)
- func (c *Concat) SetForwardBeta(beta float64)
- type Info
- type Volume
- func Build(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, ...) (*Volume, error)
- func BuildEX(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, ...) (v *Volume, err error)
- func BuildRandNorm(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, ...) (*Volume, error)
- func BuildWeights(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, ...) (*Volume, error)
- func BuildtoCudaHost(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, ...) (*Volume, error)
- func ZeroClone(h *cudnn.Handler, t *Volume) (*Volume, error)
- func (t *Volume) AddTo(handle *cudnn.Handler, A *Volume, Ascalar, tscalar float64) error
- func (t *Volume) DataType() gocudnn.DataType
- func (t *Volume) Dims() []int32
- func (t *Volume) FD() *gocudnn.FilterD
- func (t *Volume) Format() gocudnn.TensorFormat
- func (t *Volume) Info() (Info, error)
- func (t *Volume) LoadMem(handle *cudnn.Handler, input cutil.Mem, size uint) error
- func (t *Volume) NormalRand(h *cudnn.Handler, mean, std float32) error
- func (t *Volume) OpAdd(h *cudnn.Handler, A, B *Volume, alpha1, alpha2, beta float64) error
- func (t *Volume) OpMax(h *cudnn.Handler, A, B *Volume, alpha1, alpha2, beta float64) error
- func (t *Volume) OpMin(h *cudnn.Handler, A, B *Volume, alpha1, alpha2, beta float64) error
- func (t *Volume) OpMult(h *cudnn.Handler, A, B *Volume, alpha1, alpha2, beta float64) error
- func (t *Volume) OpNot(h *cudnn.Handler, A *Volume, alpha1, beta float64) error
- func (t *Volume) OpSqrt(h *cudnn.Handler, A *Volume, alpha1, beta float64) error
- func (t *Volume) Properties() (gocudnn.TensorFormat, gocudnn.DataType, []int32, error)
- func (t *Volume) SIB() uint
- func (t *Volume) ScaleValues(handle *cudnn.Handler, alpha float64) error
- func (t *Volume) SetNotPropNan()
- func (t *Volume) SetPropNan()
- func (t *Volume) SetRandom(mean, max, fanin float64) error
- func (t *Volume) SetRandomNormal(handle *cudnn.Handler, min, max float32) error
- func (t *Volume) SetValues(handle *cudnn.Handler, input float64) error
- func (t *Volume) String() string
- func (t *Volume) TD() *gocudnn.TensorD
- func (t *Volume) TDStrided() *gocudnn.TensorD
- func (t *Volume) ToImages(handle *cudnn.Handler) ([][]image.Image, error)
- func (t *Volume) ToImagesColor(h *cudnn.Handler) ([][]image.Image, error)
- func (t *Volume) ToOneImageColor(h *cudnn.Handler, X, Y int) (image.Image, error)
- func (t *Volume) TogglePrintValueForStringer()
- func (t *Volume) Vol() int32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeJPG ¶
MakeJPG will make a JPG file for the image passed it can be sepperated by neurons and the such
func ToOneImage ¶
ToOneImage will spread out the image.Images into one image.Image. It will only work if all the [][]image.Image are the same size Channels will be in the x direction, and neurons will be in the y direction. X and Y are the amount of separation in pixels in the given dim between images. The separator will be in the color black!
Types ¶
type Concat ¶
type Concat struct {
// contains filtered or unexported fields
}
Concat concats the channels of multiple tensors into a new tensor. Concats are seperated by batch.
func CreateConcat ¶
CreateConcat creates a concat handler. It contains the kernel that does the concat operation on the gpu Default alpha, beta are set to alpha = 1, beta =0.
func (*Concat) Backward ¶
Backward does the backward algorithm where the data in dest goes to the srcs.
func (*Concat) GetOutputDimsfromInputDims ¶
func (c *Concat) GetOutputDimsfromInputDims(srcs [][]int32, frmt gocudnn.TensorFormat) ([]int32, error)
GetOutputDimsfromInputDims gets the outputdims from the inputdims. If srcs dims other than the channel dims not equal. Function will return an error.
func (*Concat) GetOutputdims ¶
GetOutputdims returns the output dims of the tensor for the outputed Volume.
func (*Concat) SetBackwardAlpha ¶
SetBackwardAlpha sets the backward alpha
func (*Concat) SetBackwardBeta ¶
SetBackwardBeta sets the backward beta
func (*Concat) SetForwardAlpha ¶
SetForwardAlpha sets the forward alpha
func (*Concat) SetForwardBeta ¶
SetForwardBeta sets the forward beta
type Info ¶
type Info struct { Format gocudnn.TensorFormat `json:"Format,omitempty"` DataType gocudnn.DataType `json:"DataType,omitempty"` Nan gocudnn.NANProp `json:"Nan,omitempty"` Dims []int32 `json:"Dims,omitempty"` Stride []int32 `json:"Stride,omitempty"` MaxDims []int32 `json:"max_dims,omitempty"` Data []byte `json:"data,omitempty"` }
Info struct contains the info that is needed to build a volume
type Volume ¶
Volume holds both a gocudnn.TensorD and gocudnn.FilterD and the allocated memory associated with it
func Build ¶
func Build(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, dims []int32) (*Volume, error)
Build creates a tensor and mallocs the memory for the tensor.
func BuildEX ¶
func BuildEX(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, dims []int32, mem *nvidia.Malloced) (v *Volume, err error)
BuildEX builds a volume with settings passed. And uses the mem passed as its memory. if mem is nil function will allocate memory to gpu itself
func BuildRandNorm ¶
func BuildRandNorm(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, currentdims []int32, mean, std float32) (*Volume, error)
BuildRandNorm sets a randomnorm volume that can have its values set to random values over and over again
func BuildWeights ¶
func BuildWeights(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, dims []int32) (*Volume, error)
BuildWeights builds the weights
func BuildtoCudaHost ¶
func BuildtoCudaHost(handle *cudnn.Handler, frmt gocudnn.TensorFormat, dtype gocudnn.DataType, startdims []int32) (*Volume, error)
BuildtoCudaHost stores the tensor memory to paged memory
func (*Volume) AddTo ¶
AddTo formula is (t *Tensor)= alpha*(A)+beta*(t *Tensor) Dim max is 5. Number of dims need to be the same. Dim size need to match or be equal to 1. In the later case the same value from the A tensor for the dims will be used to blend into (t *Tensor).
func (*Volume) Format ¶
func (t *Volume) Format() gocudnn.TensorFormat
Format returns the format of the volume
func (*Volume) Info ¶
Info returns an Info struct that is used for saving info. If an error is returned then the values of Info will be set to default golang's default
func (*Volume) LoadMem ¶
LoadMem will Load the volume with the inputed mem. Input mem with the size of size
func (*Volume) NormalRand ¶
NormalRand sets the values in the volume to some Normalized Noise
func (*Volume) OpMax ¶
OpMax does max comparison Operation C = op ( alpha1[0] * A, alpha2[0] * B ) + beta[0] * C,
func (*Volume) OpMin ¶
OpMin does min comparison Operation C = op ( alpha1[0] * A, alpha2[0] * B ) + beta[0] * C,
func (*Volume) OpMult ¶
OpMult does a multiplication Operation C = op ( alpha1[0] * A, alpha2[0] * B ) + beta[0] * C,
func (*Volume) OpNot ¶
OpNot does negation Operation performed on only the A C = op ( alpha1[0] * A) + beta[0] * C,
func (*Volume) Properties ¶
Properties returns the properties of the tensor
func (*Volume) ScaleValues ¶
ScaleValues values will scale the values to the scalar passed
func (*Volume) SetNotPropNan ¶
func (t *Volume) SetNotPropNan()
SetNotPropNan will set the nan propigation flag to NotPropigationNan (NotPropigationNan is default)
func (*Volume) SetPropNan ¶
func (t *Volume) SetPropNan()
SetPropNan will change the default nan propigation flag from PropNanNon to PropNaN
func (*Volume) SetRandom ¶
SetRandom sets Random Value to weights Double and Float datatype only supported
func (*Volume) SetRandomNormal ¶
SetRandomNormal sets random numbers for values in volume
func (*Volume) SetValues ¶
SetValues sets all the values in the tensor to whatever is passed. It does this by looking at the format that is held in the tensor descriptor and auto retypes it. Documentation states that you have to pass a value that is the same type as the DataType. input is typecase
func (*Volume) ToImages ¶
ToImages makes a 2d array of images. If it is a filter then it will be listed by the images[x][y] x is the neurons. y is the feature maps for neuron x if it is a tensor then x is the batch. y is the channel. It doesn't matter what format was used
func (*Volume) ToImagesColor ¶
ToImagesColor makes a 2d array of images. Negative will be Green. Positive will be purple it returns a double array of image.Image. Only Float32 support right now
func (*Volume) ToOneImageColor ¶
ToOneImageColor will return an image.Image of the volume in batch/neuron for the rows, and channels for the column Y and X represent how much padding of (hopefully black) there is between the channels and neurons
func (*Volume) TogglePrintValueForStringer ¶
func (t *Volume) TogglePrintValueForStringer()
TogglePrintValueForStringer is for debugging. It will include the array values in String().