Skip to main content
 首页 » 编程设计

python之tensorflow 2.0.0 中 tf.one_hot 的等效项是什么

2024年09月03日26mayingbao

 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}}

请您参考如下方法:

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.