LandCoverSegmentation/semantic_segmentation/loss.py
def make_one_hot(self, labels):
        '''
        Converts an integer label torch.autograd.Variable to a one-hot Variable.
        Parameters
        ----------
        labels : torch.autograd.Variable of torch.cuda.LongTensor
            N x 1 x H x W, where N is batch size.
            Each value is an integer representing correct classification.
        C : integer.
            number of classes in labels.
        Returns
        -------
        target : torch.autograd.Variable of torch.cuda.FloatTensor
            N x C x H x W, where C is class number. One-hot encoded.
        '''

        one_hot = torch.FloatTensor(labels.size(0), self.num_c, labels.size(2), labels.size(3)).zero_()
        target = one_hot.scatter_(1, labels.cpu().data, 1)
        target = Variable(target)
        return target

        Converts an integer label torch.autograd.Variable to a one-hot Variable.
        Parameters
        ----------
        labels : torch.autograd.Variable of torch.cuda.LongTensor
            N x 1 x H x W, where N is batch size.
            Each value is an integer representing correct classification.
        C : integer.
            number of classes in labels.
        Returns
        -------
        target : torch.autograd.Variable of torch.cuda.FloatTensor
            N x C x H x W, where C is class number. One-hot encoded.
        
Converts an integer label torch.autograd.Variable to a one-hot Variable.
Parameters

labels : torch.autograd.Variable of torch.cuda.LongTensor
N x 1 x H x W, where N is batch size.
Each value is an integer representing correct classification.
C : integer.
number of classes in labels.
Returns

target : torch.autograd.Variable of torch.cuda.FloatTensor
N x C x H x W, where C is class number. One-hot encoded.
Converts an integer label torch . autograd . Variable to a one - hot Variable . Parameters labels : torch . autograd . Variable of torch . cuda . LongTensor N x 1 x H x W where N is batch size . Each value is an integer representing correct classification . C : integer . number of classes in labels . Returns target : torch . autograd . Variable of torch . cuda . FloatTensor N x C x H x W where C is class number . One - hot encoded .
def make_one_hot(self, labels):
        one_hot = torch.FloatTensor(labels.size(0), self.num_c, labels.size(2), labels.size(3)).zero_()
        target = one_hot.scatter_(1, labels.cpu().data, 1)
        target = Variable(target)
        return target
def make_one_hot ( self , labels ) : one_hot = torch . FloatTensor ( labels . size ( 0 ) , self . num_c , labels . size ( 2 ) , labels . size ( 3 ) ) . zero_ ( ) target = one_hot . scatter_ ( 1 , labels . cpu ( ) . data , 1 ) target = Variable ( target ) return target
Converts an integer label torch.autograd.Variable to a one-hot Variable.
Converts an integer label torch . autograd . Variable to a one - hot Variable .
'''
        Converts an integer label torch.autograd.Variable to a one-hot Variable.
        Parameters
        ----------
        labels : torch.autograd.Variable of torch.cuda.LongTensor
            N x 1 x H x W, where N is batch size.
            Each value is an integer representing correct classification.
        C : integer.
            number of classes in labels.
        Returns
        -------
        target : torch.autograd.Variable of torch.cuda.FloatTensor
            N x C x H x W, where C is class number. One-hot encoded.
        '''
self
labels