sgu

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package sgu implements the Spatial Gating Unit (SGU). Reference: `Pay Attention to MLPs` by Liu et al, 2021 (https://arxiv.org/pdf/2105.08050.pdf)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Dim        int
	DimSeq     int
	InitEps    mat.Float
	Activation ag.OpName
}

Config provides configuration parameters for Model.

type Model

type Model struct {
	nn.BaseModel
	Config Config
	Norm   *layernorm.Model
	Proj   *conv1x1.Model
	Act    *activation.Model
}

Model contains the serializable parameters.

func New

func New(config Config) *Model

New returns a new Model 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) Initialize

func (m *Model) Initialize(seed uint64)

Initialize set the projection weights as near-zero values and the biases as ones to improve training stability.

Jump to

Keyboard shortcuts

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