gorgonia / tensor

package tensor provides efficient and generic n-dimensional arrays in Go that are useful for machine learning and deep learning purposes
Apache License 2.0
359 stars 49 forks source link

Clarify Semantics breaks Slicing on vectors with shape 1 #102

Closed chewxy closed 3 years ago

chewxy commented 3 years ago

To reproduce:

    v = tensor.New(
        tensor.WithShape(1),
        tensor.WithBacking([]float64{2}),
    )
    sliced, err = v.Slice(gorgonia.S(0))
    handleErr(err)
    fmt.Printf("[0:1]\n%v\n%v\n\n", sliced.Shape(), sliced)

yields

panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
gorgonia.org/tensor.(*AP).S(0xc000298400, 0x1, 0xc000159e98, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/dcuadrado/go/src/gorgonia.org/tensor/ap.go:243 +0xcfc

h/t @dcu