gru

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	nn.Module
	WPart    *nn.Param
	WPartRec *nn.Param
	BPart    *nn.Param
	WRes     *nn.Param
	WResRec  *nn.Param
	BRes     *nn.Param
	WCand    *nn.Param
	WCandRec *nn.Param
	BCand    *nn.Param
}

Model contains the serializable parameters.

func New

func New[T float.DType](in, out int) *Model

New returns a new model with parameters initialized to zeros.

func (*Model) Forward

func (m *Model) Forward(xs ...mat.Tensor) []mat.Tensor

Forward performs the forward step for each input node and returns the result.

func (*Model) Next

func (m *Model) Next(state *State, x mat.Tensor) (s *State)

Next performs a single forward step, producing a new state.

r = sigmoid(wr (dot) x + br + wrRec (dot) yPrev) p = sigmoid(wp (dot) x + bp + wpRec (dot) yPrev) c = f(wc (dot) x + bc + wcRec (dot) (yPrev * r)) y = p * c + (1 - p) * yPrev

type State

type State struct {
	R mat.Tensor
	P mat.Tensor
	C mat.Tensor
	Y mat.Tensor
}

State represent a state of the GRU recurrent network.

Jump to

Keyboard shortcuts

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