def to_one_hot(y, nb_class, dtype=None):
 ret = theano.tensor.zeros((y.shape[0], nb_class), dtype=dtype)
 ret = theano.tensor.set_subtensor(ret[(theano.tensor.arange(y.shape[0]), y)], 1)
 return ret

def to_one_hot ( y , nb_class , dtype = None ) : ret = theano . tensor . zeros ( ( y . shape [ 0 ] , nb_class ) , dtype = dtype ) ret = theano . tensor . set_subtensor ( ret [ ( theano . tensor . arange ( y . shape [ 0 ] ) , y ) ] , 1 ) return ret
return a matrix where each row correspond to the one hot encoding of each element in y .