ankane / torch.rb

Deep learning for Ruby, powered by LibTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docs: Warning on target size difference

bockets opened this issue · comments

target = Torch.randn(10) # a dummy target, for example

I think this line is supposed to be target = Torch.randn(1, 10) rather than target = Torch.randn(10) to fit in with the sample code that precedes this line.

Otherwise I get the warning:

Using a target size ([10]) that is different to the input size ([1, 10]). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.

Hi @bockets, thanks for another report, but I'm not able to reproduce the warning. That line and the next one will give target a shape of [1, 10].

target = Torch.randn(10) # a dummy target, for example
target = target.view(1, -1) # make it the same shape as output