mlpmixer

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: 9 Imported by: 0

Documentation

Overview

Package mlpmixer implements the MLP-Mixer (Tolstikhin et al., 2021).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	InputSize               int
	HiddenSizeTokenMixer    int
	HiddenSizeChannelMixer  int
	Channels                int
	ActFunctionTokenMixer   activation.Activation
	ActFunctionChannelMixer activation.Activation
	Eps                     float64
}

Config provides configuration settings for a MixerBlock.

type FeedForward

type FeedForward struct {
	nn.Module
	Layers nn.ModuleList[nn.StandardModel]
}

FeedForward is the model for feed-forward operations of a MixerBlock.

func (*FeedForward) Forward

func (m *FeedForward) Forward(xs ...mat.Tensor) []mat.Tensor

type MixerBlock

type MixerBlock struct {
	nn.Module
	Config
	TokenLayerNorm   *layernorm.Model
	TokenMixerFF     *FeedForward
	ChannelLayerNorm *layernorm.Model
	ChannelMixerFF   *FeedForward
}

MixerBlock contains the serializable parameters.

func New

func New[T float.DType](config Config) *MixerBlock

New returns a new model with parameters initialized to zeros.

func (*MixerBlock) Forward

func (m *MixerBlock) Forward(xs ...mat.Tensor) []mat.Tensor

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

Jump to

Keyboard shortcuts

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