Tensorflow One Hot Encoder?

后端 未结 15 1726
一生所求
一生所求 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:39

    You can use tf.sparse_to_dense:

    The sparse_indices argument indicates where the ones should go, output_shape should be set to the number of possible outputs (e.g. the number of labels), and sparse_values should be 1 with the desired type (it will determine the type of the output from the type of sparse_values).

提交回复
热议问题