Skip to main content

Sequential

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

Sequential runs its modules in order, releasing every intermediate tensor it produced (the caller's input and the returned output are untouched). With zero modules, Forward returns the input itself.

The container takes ownership of the modules passed to it: Sequential.Close closes every child that has a Close.

Constructors and associated declarations

NewSequential

func NewSequential(modules ...Module) *Sequential

NewSequential chains the given modules: Forward(x) runs them left to right.

Methods

Close

func (s *Sequential) Close()

Close closes every child module that has a Close (a Linear, a nested Sequential, any closable custom module).

Forward

func (s *Sequential) Forward(input *clikart.Tensor) (*clikart.Tensor, error)

Forward chains the modules; intermediates are released as the chain advances, and on an error every intermediate produced so far is released before the error returns.