variable

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package variable provides a trainable variable type, analogous to tf.Variable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Variable

type Variable struct {
	// contains filtered or unexported fields
}

Variable represents a mutable NDArray that persists across calls. Analogous to tf.Variable.

func New

func New(initialValue *numgo.NDArray, name string, trainable bool) *Variable

New creates a new Variable with the given initial value and name.

func (*Variable) Assign

func (v *Variable) Assign(newValue *numgo.NDArray) error

Assign replaces the variable's value. The new value must have the same shape.

func (*Variable) AssignAdd

func (v *Variable) AssignAdd(delta *numgo.NDArray) error

AssignAdd adds an NDArray to the variable's current value in place.

func (*Variable) AssignSub

func (v *Variable) AssignSub(delta *numgo.NDArray) error

AssignSub subtracts an NDArray from the variable's current value in place.

func (*Variable) ID

func (v *Variable) ID() int64

ID returns the unique identifier of this variable.

func (*Variable) Name

func (v *Variable) Name() string

Name returns the name of this variable.

func (*Variable) NumElements

func (v *Variable) NumElements() int

NumElements returns the total number of elements in the variable.

func (*Variable) Shape

func (v *Variable) Shape() []int

Shape returns the shape of the variable's NDArray.

func (*Variable) Trainable

func (v *Variable) Trainable() bool

Trainable returns whether this variable participates in gradient computation.

func (*Variable) Value

func (v *Variable) Value() *numgo.NDArray

Value returns a copy of the current NDArray value.

Jump to

Keyboard shortcuts

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