meetps / pytorch-semseg

Semantic Segmentation Architectures Implemented in PyTorch
https://meetshah.dev/semantic-segmentation/deep-learning/pytorch/visdom/2017/06/01/semantic-segmentation-over-the-years.html
MIT License
3.38k stars 799 forks source link

cross entropy reshaping lines #222

Open brucemuller opened 5 years ago

brucemuller commented 5 years ago

Hi, thank you for your efforts!

In cross_entropy2d function in loss.py I noticed there are these reshaping lines:

input = input.transpose(1, 2).transpose(2, 3).contiguous().view(-1, c) target = target.view(-1)

Before passing into the loss calculation. Are these for efficiency? What's the main purpose?