Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multidimensional array assignment #132

Open
ashnair1 opened this issue Aug 17, 2022 · 1 comment
Open

Multidimensional array assignment #132

ashnair1 opened this issue Aug 17, 2022 · 1 comment

Comments

@ashnair1
Copy link

ashnair1 commented Aug 17, 2022

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)

@ashnair1 ashnair1 changed the title Analogue for x[0] = y Multidimensional array assignment Aug 17, 2022
@yati-sagade
Copy link

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)

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants