MCPcopy
hub / github.com/nlpodyssey/spago / Tensor

Interface Tensor

mat/tensor.go:14–47  ·  view source on GitHub ↗

Tensor represents an interface for a generic tensor.

Source from the content-addressed store, hash-verified

12
13// Tensor represents an interface for a generic tensor.
14type Tensor interface {
15 // Shape returns the size in each dimension.
16 Shape() []int
17 // Dims returns the number of dimensions.
18 Dims() int
19 // Size returns the total number of elements.
20 Size() int
21 // Data returns the underlying data of the tensor.
22 Data() float.Slice
23 // Item returns the scalar value.
24 // It panics if the matrix does not contain exactly one element.
25 Item() float.Float
26 // SetAt sets the value at the given indices.
27 // It panics if the given indices are out of range.
28 SetAt(m Tensor, indices ...int)
29 // At returns the value at the given indices.
30 // It panics if the given indices are out of range.
31 At(indices ...int) Tensor
32 // Value returns the value of the node.
33 // In case of a leaf node, it returns the value of the underlying matrix.
34 // In case of a non-leaf node, it returns the value of the operation performed during the forward pass.
35 Value() Tensor
36 // Grad returns the gradients accumulated during the backward pass.
37 // A matrix full of zeros and the nil value are considered equivalent.
38 Grad() Tensor
39 // HasGrad reports whether there are accumulated gradients.
40 HasGrad() bool
41 // RequiresGrad reports whether the node requires gradients.
42 RequiresGrad() bool
43 // AccGrad accumulates the gradients into the node.
44 AccGrad(gx Tensor)
45 // ZeroGrad zeroes the gradients, setting the value of Grad to nil.
46 ZeroGrad()
47}
48
49func init() {
50 gob.Register([]Tensor{})

Callers 4

testAffineFunction · 0.92
testAppendRowsForwardFunction · 0.92
ReverseSubOneFunction · 0.92
stdDevMethod · 0.92

Implementers 1

Operatorag/operator.go

Calls

no outgoing calls

Tested by

no test coverage detected