Skip to main content

Linear

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

Linear is a dense layer: `input @ weight^T + bias`, with an optional fused activation.

The layer RETAINS its own references to weight (and bias) at construction; the caller keeps ownership of the passed handles and may release them independently; Linear.Close drops the layer's references.

Constructors and associated declarations

NewLinear

func NewLinear(weight, bias *clikart.Tensor,
activation *clikart.Activation) *Linear

NewLinear builds the layer over weight `[out, in]` and an optional bias `[out]` (nil = none); a non-nil activation fuses an epilogue into every Forward.

Methods

Close

func (l *Linear) Close()

Close drops the layer's weight and bias references; safe to call twice.

Forward

func (l *Linear) Forward(input *clikart.Tensor) (*clikart.Tensor, error)

Forward computes the affine map; input stays valid.