Skip to content

[Lightnet 1.1.1][YoloV3] [Windows] expected type torch.FloatTensor but got torch.LongTensor

Environment

  • Windows
  • Python 3.6.7
  • Lightnet 1.1.1
  • Pytorch 1.0.1
  • network : YoloV3

The issue

In lightnet/network/loss/_regionloss.py, I got a raised error :

expected type torch.FloatTensor but got torch.LongTensor

on line 127 & 128 :

    pred_boxes[:, 2] = (coord[:, :, 2].detach().exp() * anchor_w).view(-1)
    pred_boxes[:, 3] = (coord[:, :, 3].detach().exp() * anchor_h).view(-1)

Indeed printing the different types confirms the error :

coord.type()
'torch.FloatTensor'
anchor_w.type()
'torch.LongTensor'
anchor_h.type()
'torch.LongTensor'

A similar issue occurs on lines 382 & 383 :

intersections = b1w.min(b2w) * b1h.min(b2h)
unions = (b1w * b1h) + (b1w * b1h) - intersections

and in fact the issue propagates along the rest of the code.

Edited by Tanguy Ophoff