lstm

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 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.BaseModel
	UseRefinedGates bool
	WIn             nn.Param `spago:"type:weights"`
	WInRec          nn.Param `spago:"type:weights"`
	BIn             nn.Param `spago:"type:biases"`
	WOut            nn.Param `spago:"type:weights"`
	WOutRec         nn.Param `spago:"type:weights"`
	BOut            nn.Param `spago:"type:biases"`
	WFor            nn.Param `spago:"type:weights"`
	WForRec         nn.Param `spago:"type:weights"`
	BFor            nn.Param `spago:"type:biases"`
	WCand           nn.Param `spago:"type:weights"`
	WCandRec        nn.Param `spago:"type:weights"`
	BCand           nn.Param `spago:"type:biases"`
	States          []*State `spago:"scope:processor"`
}

Model contains the serializable parameters.

func New

func New(in, out int, options ...Option) *Model

New returns a new model with parameters initialized to zeros.

func (*Model) Forward

func (m *Model) Forward(xs ...ag.Node) []ag.Node

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

func (*Model) LastState

func (m *Model) LastState() *State

LastState returns the last state of the recurrent network. It returns nil if there are no states.

func (*Model) SetInitialState

func (m *Model) SetInitialState(state *State)

SetInitialState sets the initial state of the recurrent network. It panics if one or more states are already present.

type Option

type Option func(*Model)

Option allows to configure a new Model with your specific needs.

func SetRefinedGates

func SetRefinedGates(value bool) Option

SetRefinedGates sets whether to use refined gates. Refined Gate: A Simple and Effective Gating Mechanism for Recurrent Units (https://arxiv.org/pdf/2002.11338.pdf) TODO: panic input size and output size are different

type State

type State struct {
	InG  ag.Node
	OutG ag.Node
	ForG ag.Node
	Cand ag.Node
	Cell ag.Node
	Y    ag.Node
}

State represent a state of the LSTM recurrent network.

Jump to

Keyboard shortcuts

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