Tensorflow 2.0.0中tf.one_hot的等效值是多少

时间:2019-04-16 08:56:32

标签: python tensorflow tensorflow2.0

 train_label = tf.keras.backend.one_hot(train_label,3)
 train_label = tf.one_hot(train_label,3)

在tensorflow 2.0.0中给出以下错误

InternalError: Could not find valid device for node.

节点:{{node OneHot}}

1 个答案:

答案 0 :(得分:0)

train_label应该是INT类型的数据。例如:

train_label = [1, 2 ,3]
train_label = tf.one_hot(train_label,3) // work

train_label = [1., 2., 3.]
train_label = tf.one_hot(train_label,3) // InternalError: Could not find valid device for node.