FDD/data_distillation_or2.py
def one_hot(indices, depth):
    """
    Returns a one-hot tensor.
    This is a PyTorch equivalent of Tensorflow's tf.one_hot.

    Parameters:
      indices:  a (n_batch, m) Tensor or (m) Tensor.
      depth: a scalar. Represents the depth of the one hot dimension.
    Returns: a (n_batch, m, depth) Tensor or (m, depth) Tensor.
    """
    encoded_indicies = torch.zeros(
        indices.size() + torch.Size([depth])).to(device=device)
    index = indices.view(indices.size() + torch.Size([1]))
    encoded_indicies = encoded_indicies.scatter_(1, index, 1)

    return encoded_indicies

    Returns a one-hot tensor.
    This is a PyTorch equivalent of Tensorflow's tf.one_hot.

    Parameters:
      indices:  a (n_batch, m) Tensor or (m) Tensor.
      depth: a scalar. Represents the depth of the one hot dimension.
    Returns: a (n_batch, m, depth) Tensor or (m, depth) Tensor.
    
Returns a one-hot tensor.
This is a PyTorch equivalent of Tensorflow's tf.one_hot.
Returns a one - hot tensor . This is a PyTorch equivalent of Tensorflow ' s tf . one_hot .
def one_hot(indices, depth):
    encoded_indicies = torch.zeros(
        indices.size() + torch.Size([depth])).to(device=device)
    index = indices.view(indices.size() + torch.Size([1]))
    encoded_indicies = encoded_indicies.scatter_(1, index, 1)
    return encoded_indicies
def one_hot ( indices , depth ) : encoded_indicies = torch . zeros ( indices . size ( ) + torch . Size ( [ depth ] ) ) . to ( device = device ) index = indices . view ( indices . size ( ) + torch . Size ( [ 1 ] ) ) encoded_indicies = encoded_indicies . scatter_ ( 1 , index , 1 ) return encoded_indicies
Returns a one-hot tensor.
Returns a one - hot tensor .
"""
    Returns a one-hot tensor.
    This is a PyTorch equivalent of Tensorflow's tf.one_hot.

    Parameters:
      indices:  a (n_batch, m) Tensor or (m) Tensor.
      depth: a scalar. Represents the depth of the one hot dimension.
    Returns: a (n_batch, m, depth) Tensor or (m, depth) Tensor.
    """
indices
a (n_batch, m) Tensor or (m) Tensor.
a ( n_batch m ) Tensor or ( m ) Tensor .
depth
a scalar. Represents the depth of the one hot dimension.
a scalar . Represents the depth of the one hot dimension .