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

Train.lua Line 340 throws up error ""weights input should be 1-D Tensor"" #2

Open
prashkmr opened this issue Aug 11, 2020 · 1 comment

Comments

@prashkmr
Copy link

prashkmr commented Aug 11, 2020

Hi @BertaBescos

Thanks for open sourcing your code.

I came across an issue at Line 340, in train.lua

You pass matrix to BCECriterionLoss which accepts only one-dimensional vector, which throws an error ""weights input should be 1-D Tensor"

Fulle Error:
/home/prashant/torch/install/bin/luajit: ...prashant/torch/install/share/lua/5.1/nn/BCECriterion.lua:12: weights input should be 1-D Tensor
stack traceback:
[C]: in function 'assert'
...prashant/torch/install/share/lua/5.1/nn/BCECriterion.lua:12: in function '__init'
/home/prashant/torch/install/share/lua/5.1/torch/init.lua:91: in function </home/prashant/torch/install/share/lua/5.1/torch/init.lua:87>
[C]: in function 'BCECriterion'
train.lua:339: in function 'opfunc'
/home/prashant/torch/install/share/lua/5.1/optim/adam.lua:37: in function 'adam'
train.lua:591: in main chunk
[C]: in function 'dofile'
...hant/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50

I tried to reshape the vector to one dimensional which throws up an error.

The line 339: criterionDDiscriminator = nn.BCECriterion(weightsDiscriminator)
is expecting 1-D tensor as input to BCECriterion whereas the "weightsDiscriminator" is not one-dimensional
I an running CUDA 9.0 with cuDNN 5. It doesn't look like any compatibility issue with CUDA or any such thing.

Can you shed some light here? It would of great help.

Thanks,
Prashant

@abhinavj98
Copy link

Replacing BCECriterion with WeightedBCECriterion on line 339 which is defined in criterion.lua solves this issue

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