gorgonia/tensor

Multidimensional array assignment

Opened this issue · 1 comments

Given an array x of shape (3, 100, 100), does gorgonia/tensor have a way to do

x[0] = y
x[1] = z
x[2] = w

where w, y and z are of shape (100, 100)

You can do something like:

import (
	"gorgonia.org/tensor"
)

...

s, err := x.Slice(tensor.S(0), nil, nil) // x[0, :, :]
if err != nil { ... }
tensor.Copy(s, y) // Note: dst, src.

s, err := x.Slice(tensor.S(1), nil, nil) // x[1, :, :]
if err != nil { ... }
tensor.Copy(s, z)

...