Documentation ¶
Overview ¶
package qol provides quality-of-life utilities for working with neural networks in Gorgonia.
Index ¶
- func ClassType() tensor.Dtype
- func OneHotMatrix(a []Class, numClasses uint, dtype tensor.Dtype, opts ...G.NodeConsOpt) *G.Node
- func OneHotVector(a Class, numClasses uint, dtype tensor.Dtype, opts ...G.NodeConsOpt) *G.Node
- func ToOneHotMatrix(a []Class, numClasses uint, dtype tensor.Dtype) *tensor.Dense
- func ToOneHotVector(a Class, numClasses uint, dtype tensor.Dtype) *tensor.Dense
- func UnsafeToOneHotMatrix(a []Class, numClasses uint, reuse *tensor.Dense) *tensor.Dense
- func UnsafeToOneHotVector(a Class, numClasses uint, reuse *tensor.Dense) *tensor.Dense
- type Class
- type Classes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassType ¶
ClassType returns the tensor.Dtype for Class. This allows it to be used in Gorgonia graphs.
func OneHotMatrix ¶
OneHotMatrix creates a node that represents a one-hot matrix.
func OneHotVector ¶
OneHotVector creates a node that represents a one-hot vector.
func ToOneHotMatrix ¶
ToOneHotMatrix converts a slice of Class to a OneHotMatrix.
The dtype defaults to tensor.Float64 if an empty Dtype was passed in.
func ToOneHotVector ¶
ToOneHotVector converts a Class to a OneHotVector.
The dtype defaults to tensor.Float64 if an empty Dtype was passed in.
func UnsafeToOneHotMatrix ¶
UnsafeToOneHotMatrix converts a slice of Class to a OneHotMatrix, in the given tensor.Tensor. It expects a matrix of shape (len(a), numClasses). Panics otherwise.
Types ¶
type Class ¶
type Class uint
Class represents the class ID of a dataset. It is an unbound type with a minimum of 0.
func ToClass ¶
ToClass converts a OneHotVector to a Class. This function panics if `a` is not a vector.
The default threshold is 0.55 if 0 is passed in. The threshold does not apply to int tensors.
Some behavioural notes: This function is NOT an argmax function. If the following vector is passed in,
[0.1 0.1 0.6 0.7 0.1]
the class returned will be 2, not 3.
The same behaviour applies to `int` an `uint` tensor.
For int Tensors, it assumes any value larger or equal to 1 is 1, and any value < 0 is 0. So the Class of the following:
[0 -1 3 3 1 0]
will also be 2.
func ToClasses ¶
ToClass converts a OneHotMatrix to Classes. This function panics if `a` is not a matrix. The default threshold is 0.55 if 0 is passed in. The threshold does not apply to int tensors.
Some behavioural notes: This function is NOT an argmax function. If the following matrix is passed in,
[0.1 0.1 0.6 0.7 0.1] [0.6 0.1 0.1 0.7 0.1]
the class returned will be [2 0], not [3 3].
The same behaviour applies to `int` an `uint` tensor.
For int Tensors, it assumes any value larger or equal to 1 is 1, and any value < 0 is 0. So the Class of the following:
[0 -1 3 3 1 0] [2 0 -1 3 0 0]
will also be [2 0] and not [2 3] or [3 3].