EmptyCities_SLAM icon indicating copy to clipboard operation
EmptyCities_SLAM copied to clipboard

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

Open prashkmr opened this issue 5 years ago • 1 comments

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

prashkmr avatar Aug 11 '20 19:08 prashkmr

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

abhinavj98 avatar Aug 20 '20 08:08 abhinavj98