Tensorflow One Hot Encoder?

后端 未结 15 1700
一生所求
一生所求 2020-12-04 13:46

Does tensorflow have something similar to scikit learn\'s one hot encoder for processing categorical data? Would using a placeholder of tf.string behave as categorical data

15条回答
  •  渐次进展
    2020-12-04 14:41

    In [7]: one_hot = tf.nn.embedding_lookup(np.eye(5), [1,2])
    
    In [8]: one_hot.eval()
    Out[8]: 
    array([[ 0.,  1.,  0.,  0.,  0.],
           [ 0.,  0.,  1.,  0.,  0.]])
    

    works on TF version 1.3.0. As of Sep 2017.

提交回复
热议问题