slstm

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

Overview

Package slstm implements a Sentence-State LSTM graph neural network.

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
}

Config provides configuration settings for a Sentence-State LSTM Model.

type HyperLinear3

type HyperLinear3 struct {
	nn.Module
	W *nn.Param
	U *nn.Param
	B *nn.Param
}

HyperLinear3 groups multiple params for an affine transformation.

type HyperLinear4

type HyperLinear4 struct {
	nn.Module
	W *nn.Param
	U *nn.Param
	V *nn.Param
	B *nn.Param
}

HyperLinear4 groups multiple params for an affine transformation.

type Model

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

Model contains the serializable parameters.

func New

func New[T float.DType](config Config) *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.

type State

type State struct {
	ViPrevG mat.Tensor
	VlPrevG mat.Tensor
	VrPrevG mat.Tensor
	VfPrevG mat.Tensor
	VsPrevG mat.Tensor
	VoPrevG mat.Tensor
	VuPrevG mat.Tensor
	// contains filtered or unexported fields
}

State contains nodes used during the forward step.

Jump to

Keyboard shortcuts

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