tensorflow.python.framework.errors_impl.NotFoundError: Could not find valid device for node.

every blog every motto: You can do more than you think.

0. 前言

测试代码报错,小记

1. 正文

测试如下代码,

import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

import tensorflow as tf
import numpy as np

tensor = tf.constant(np.arange(12).reshape((3, 4,1))) 
print(tensor)

temp = tf.sigmoid(tensor)
print(temp)

报错:

tensorflow.python.framework.errors_impl.NotFoundError: Could not find valid device for node.

原因:tensor为浮点型才可进行tf.sigmoid运算


修正后:

import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

import tensorflow as tf
import numpy as np

tensor = tf.constant(np.arange(12).reshape((3, 4, 1)), dtype=tf.float32)
print(tensor)

temp = tf.sigmoid(tensor)
print(temp)

参考文献

猜你喜欢

转载自blog.csdn.net/weixin_39190382/article/details/109380454
今日推荐