Tensor.toarray
- Tensor.toarray()
Return a copy of the Tensor’s data as a shaped numpy array.
The shape follows the Tensor’s variable order: the last variable added varies fastest (C order), so the shape is
tuple(reversed(self.shape)).- Returns:
New float64 array; modifying it does not affect the Tensor.
- Return type:
numpy.ndarray
Example
import pyagrum as gum
a, b = gum.LabelizedVariable("a", "a", 2), gum.LabelizedVariable("b", "b", 3)
p = gum.Tensor().add(a).add(b).fillWith([1, 2, 3, 4, 5, 6])
p.toarray()
# array([[1., 2.],
# [3., 4.],
# [5., 6.]])
Class