modules/layer.py
def onehot_encode(self, input):
        """
        Returns a one-hot vector corresponding to the input

        Args:
            input (B,): torch.LongTensor of item indices
            buffer (B,output_size): buffer that stores the one-hot vector
        Returns:
            one_hot (B,C): torch.FloatTensor of one-hot vectors
        """
        
        self.onehot_buffer.zero_()
        index = input.view(-1,1)
        one_hot = self.onehot_buffer.scatter_(1, index, 1)
        
        return one_hot

        Returns a one-hot vector corresponding to the input

        Args:
            input (B,): torch.LongTensor of item indices
            buffer (B,output_size): buffer that stores the one-hot vector
        Returns:
            one_hot (B,C): torch.FloatTensor of one-hot vectors
        
Returns a one-hot vector corresponding to the input
Returns a one - hot vector corresponding to the input
def onehot_encode(self, input):
        self.onehot_buffer.zero_()
        index = input.view(-1,1)
        one_hot = self.onehot_buffer.scatter_(1, index, 1)
        return one_hot
def onehot_encode ( self , input ) : self . onehot_buffer . zero_ ( ) index = input . view ( - 1 , 1 ) one_hot = self . onehot_buffer . scatter_ ( 1 , index , 1 ) return one_hot
Returns a one-hot vector corresponding to the input
Returns a one - hot vector corresponding to the input
"""
        Returns a one-hot vector corresponding to the input

        Args:
            input (B,): torch.LongTensor of item indices
            buffer (B,output_size): buffer that stores the one-hot vector
        Returns:
            one_hot (B,C): torch.FloatTensor of one-hot vectors
        """
one_hot (B,C): torch.FloatTensor of one-hot vectors
one_hot ( B C ) : torch . FloatTensor of one - hot vectors
self
input
torch.LongTensor of item indices
torch . LongTensor of item indices
buffer
buffer that stores the one-hot vector
buffer that stores the one - hot vector