slstm

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

slstm Reference: "Sentence-State LSTM for Text Representation" by Zhang et al, 2018. (https://arxiv.org/pdf/1805.02474.pdf)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	InputSize  int
	OutputSize int
	Steps      int
}

type HyperLinear3

type HyperLinear3 struct {
	W *nn.Param `type:"weights"`
	U *nn.Param `type:"weights"`
	B *nn.Param `type:"biases"`
}

HyperLinear4 groups multiple params for an affine transformation.

type HyperLinear4

type HyperLinear4 struct {
	W *nn.Param `type:"weights"`
	U *nn.Param `type:"weights"`
	V *nn.Param `type:"weights"`
	B *nn.Param `type:"biases"`
}

HyperLinear4 groups multiple params for an affine transformation.

type Model

type Model struct {
	Config                 Config
	InputGate              *HyperLinear4 `type:"params"`
	LeftCellGate           *HyperLinear4 `type:"params"`
	RightCellGate          *HyperLinear4 `type:"params"`
	CellGate               *HyperLinear4 `type:"params"`
	SentCellGate           *HyperLinear4 `type:"params"`
	OutputGate             *HyperLinear4 `type:"params"`
	InputActivation        *HyperLinear4 `type:"params"`
	NonLocalSentCellGate   *HyperLinear3 `type:"params"`
	NonLocalInputGate      *HyperLinear3 `type:"params"`
	NonLocalSentOutputGate *HyperLinear3 `type:"params"`
	StartH                 *nn.Param     `type:"weights"`
	EndH                   *nn.Param     `type:"weights"`
	InitValue              *nn.Param     `type:"weights"`
}

Model contains the serializable parameters.

func New

func New(config Config) *Model

New returns a new model with parameters initialized to zeros.

func (*Model) NewProc

func (m *Model) NewProc(ctx nn.Context) nn.Processor

NewProc returns a new processor to execute the forward step.

type Processor

type Processor struct {
	nn.BaseProcessor
	Config Config
	// InputGate
	Wi, Ui, Vi, Bi ag.Node
	// LeftCellGate
	Wl, Ul, Vl, Bl ag.Node
	// RightCellGate
	Wr, Ur, Vr, Br ag.Node
	// CellGate
	Wf, Uf, Vf, Bf ag.Node
	// SentCellGate
	Ws, Us, Vs, Bs ag.Node
	// OutputGate
	Wo, Uo, Vo, Bo ag.Node
	// InputActivation
	Wu, Uu, Vu, Bu ag.Node
	// NonLocalSentCellGate
	NLSentWg, NLSentUg, NLSentBg ag.Node
	// NonLocalInputGate
	NLSentWf, NLSentUf, NLSentBf ag.Node
	// NonLocalSentOutputGate
	NLSentWo, NLSentUo, NLSentBo ag.Node
	// Start/End Hidden
	StartH, EndH ag.Node
	// Values at t0
	InitValue ag.Node

	// Shared among all nodes at the same step
	ViPrevG ag.Node
	VlPrevG ag.Node
	VrPrevG ag.Node
	VfPrevG ag.Node
	VsPrevG ag.Node
	VoPrevG ag.Node
	VuPrevG ag.Node
	// contains filtered or unexported fields
}

func (*Processor) Forward

func (p *Processor) Forward(xs ...ag.Node) []ag.Node

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

Jump to

Keyboard shortcuts

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