lstmsc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package lstmsc provides an implementation of LSTM enriched with a PolicyGradient to enable Dynamic Skip Connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	nn.BaseModel
	PolicyGradient *stack.Model
	Lambda         float64
	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, k int, lambda float64, intermediate int) *Model

New returns a new model with parameters initialized to zeros. Lambda is the coefficient used in the equation λa + (1 − λ)b where 'a' is state[t-k] and 'b' is state[t-1].

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) PolicyGradientLogProbActions

func (m *Model) PolicyGradientLogProbActions() []ag.Node

PolicyGradientLogProbActions returns the log probabilities for each action estimated by the policy gradient.

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 State

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

State represent a state of the LSTM with Dynamic Skip Connections recurrent network.

Jump to

Keyboard shortcuts

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