recurrent

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleRNN

type SimpleRNN[T tensor.Numeric] struct {
	// contains filtered or unexported fields
}

SimpleRNN is a simple recurrent neural network layer. It maintains a hidden state that is updated at each forward pass. newState = tanh(Wx*x + Wh*h + b)

func NewSimpleRNN

func NewSimpleRNN[T tensor.Numeric](
	name string,
	engine compute.Engine[T],
	ops numeric.Arithmetic[T],
	inputDim, hiddenDim int,
) (*SimpleRNN[T], error)

NewSimpleRNN creates a new SimpleRNN layer.

func (*SimpleRNN[T]) Attributes

func (r *SimpleRNN[T]) Attributes() map[string]interface{}

Attributes returns the attributes of the layer.

func (*SimpleRNN[T]) Backward

func (r *SimpleRNN[T]) Backward(ctx context.Context, mode types.BackwardMode, outputGradient *tensor.TensorNumeric[T], inputs ...*tensor.TensorNumeric[T]) ([]*tensor.TensorNumeric[T], error)

Backward computes the gradients.

func (*SimpleRNN[T]) Forward

func (r *SimpleRNN[T]) Forward(ctx context.Context, inputs ...*tensor.TensorNumeric[T]) (*tensor.TensorNumeric[T], error)

Forward performs the forward pass. It takes one input: the current input to the sequence. The hidden state is managed internally.

func (*SimpleRNN[T]) OpType

func (r *SimpleRNN[T]) OpType() string

OpType returns the operation type.

func (*SimpleRNN[T]) OutputShape

func (r *SimpleRNN[T]) OutputShape() []int

OutputShape returns the output shape of the layer.

func (*SimpleRNN[T]) Parameters

func (r *SimpleRNN[T]) Parameters() []*graph.Parameter[T]

Parameters returns the trainable parameters of the layer.

Jump to

Keyboard shortcuts

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