tensorfow NotFoundError: Could not find valid device for node. Node:{{node Tanh}}问题

使用tensorfolw2 tf.tanh函数,出现NotFoundError: Could not find valid device for node.错误:

>>> a = tf.range(-2,3)
>>> a

>>> tf.tanh(a)
NotFoundError:** Could not find valid device for node.
Node:{{node Tanh}}
All kernels registered for op Tanh :
  device='CPU'; T in [DT_FLOAT]
  device='CPU'; T in [DT_HALF]
  device='CPU'; T in [DT_DOUBLE]
  device='CPU'; T in [DT_COMPLEX64]
  device='CPU'; T in [DT_COMPLEX128]
  device='GPU'; T in [DT_FLOAT]
  device='GPU'; T in [DT_HALF]
  device='GPU'; T in [DT_DOUBLE]
 [Op:Tanh]

解决办法,把tensor转换成float 形式

>>> a = tf.range(-2,3,dtype=tf.float32)
>>> a


>>> tf.tanh(a)


你可能感兴趣的:(Tensorflow)