decoder

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Decoder

The decoder package provides standalone decoders that can sample variables from emer network layers.

SoftMax

The SoftMax decoder is the best choice for a 1-hot classification decoder.

Call Init to initialize with number of categories and layers for input.

Call Decode

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SoftMax

type SoftMax struct {
	Lrate    float32                     `def:"0.1" desc:"learning rate"`
	Layers   []emer.Layer                `desc:"layers to decode"`
	NCats    int                         `desc:"number of different categories to decode"`
	Units    []Unit                      `desc:"unit values"`
	Sorted   []int                       `` /* 183-byte string literal not displayed */
	NInputs  int                         `desc:"number of inputs -- total sizes of layer inputs"`
	Inputs   []float32                   `desc:"input values, copied from layers"`
	Targ     int                         `desc:"current target index of correct category"`
	ValsTsrs map[string]*etensor.Float32 `view:"-" desc:"for holding layer values"`
	Weights  etensor.Float32             `desc:"synaptic weights: outer loop is units, inner loop is inputs"`
}

SoftMax is a softmax decoder

func (*SoftMax) Back

func (sm *SoftMax) Back()

Back compute the backward error propagation pass

func (*SoftMax) Decode

func (sm *SoftMax) Decode(varNm string) int

Decode decodes the given variable name from layers (forward pass) See Sorted list of indexes for the decoding output -- i.e., Sorted[0] is the most likely -- that is returned here as a convenience.

func (*SoftMax) Forward

func (sm *SoftMax) Forward()

Forward compute the forward pass from input

func (*SoftMax) Init

func (sm *SoftMax) Init(ncats, ninputs int)

Init initializes detector with number of categories and number of inputs

func (*SoftMax) InitLayer

func (sm *SoftMax) InitLayer(ncats int, layers []emer.Layer)

InitLayer initializes detector with number of categories and layers

func (*SoftMax) Input

func (sm *SoftMax) Input(varNm string)

Input grabs the input from given variable in layers

func (*SoftMax) Sort

func (sm *SoftMax) Sort()

Sort updates Sorted indexes of the current Unit category activations sorted from highest to lowest. i.e., the 0-index value has the strongest decoded output category, 1 the next-strongest, etc.

func (*SoftMax) Train

func (sm *SoftMax) Train(targ int)

Train trains the decoder with given target correct answer (0..NCats-1)

func (*SoftMax) ValsTsr

func (sm *SoftMax) ValsTsr(name string) *etensor.Float32

ValsTsr gets value tensor of given name, creating if not yet made

type Unit

type Unit struct {
	Act float32 `desc:"final activation = e^Ge / sum e^Ge"`
	Net float32 `desc:"net input = sum x * w"`
	Exp float32 `desc:"exp(Net)"`
}

Unit has variables for decoder unit

Jump to

Keyboard shortcuts

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