FluxML / FluxML/Torch.jl

2D tensors should be reversed?

Open
#36 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
240
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Hi,
When implementing a linear layer, the following code does not produce the expected output:
```Julia
import Torch: tensor
W = collect(reshape(1.f0:6.f0, (3,2)))
x = reshape([1.f0; 1.f0], (2, 1))
expected = W * x
output = tensor(W, dev = 0) * tensor(x, dev = 0)
```
I noted that 2d and nd tensors are treated differently and to me this looks like the root cause:
https://github.com/FluxML/Torch.jl/blob/master/src/tensor.jl#L143-L149

Is there a good reason to treat them differently?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the Julia example in the issue and compare tensor(W) * tensor(x) with W * x. Read src/tensor.jl around lines 143-149, where 2D and higher-dimensional tensors are treated differently. Done means determining whether that distinction causes the mismatch and documenting or correcting the behavior so the tensor result matches the stated expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.