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

Slice bug "drop any dimension with size 1" #208

Closed
matdodgson opened this issue May 26, 2018 · 2 comments
Closed

Slice bug "drop any dimension with size 1" #208

matdodgson opened this issue May 26, 2018 · 2 comments

Comments

@matdodgson
Copy link

matdodgson commented May 26, 2018

Hi.

Just starting to take a look at the Gorgonia Tensor library for some ML vision stuff. I've found that Slice() is not behaving like Numpy, and my feeling is that this is a bug. Please see the following test code:

func TestSlice1(t *testing.T) {
	a := tensor.New(tensor.WithShape(2, 2), tensor.WithBacking([]int{1, 2, 3, 4}))

	err := a.Reshape(1, 1, 2, 2)
	if err != nil {
		panic("bad reshape")
	}

	c, err := a.Slice(gorgonia.S(0), nil, nil, nil)
	if err != nil {
		panic("bad slice")
	}

	if len(c.Shape()) != 3 {
		t.Errorf("bad shape %v", c.Shape())
	}
}

After the reshape the Tensor has dimensions 1,1,2,2. After the slice it is 2,2. Since I pass nil as the 2nd parameter to Slice(), my feeling is that it should not remove that dimension, but it does.

If I submit a pull request to fix this, will it be accepted? It's a very simple fix, but could have repercussions if others are using a work around.

@chewxy
Copy link
Member

chewxy commented May 26, 2018

You are correct. It is a bug. Bug free is more important than anyone's workflow being preserved. Let's bring this to the right repo, shall we?

@chewxy
Copy link
Member

chewxy commented May 26, 2018

github does not have issue moving features - this fix and the PR by @matdodgson can be found here: gorgonia/tensor#30

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