为了账号安全,请及时绑定邮箱和手机立即绑定

急切执行-InternalError:找不到节点名称为“ Sqrt”的有效设备

急切执行-InternalError:找不到节点名称为“ Sqrt”的有效设备

慕码人2483693 2021-05-10 12:22:37
启用Eager Execution后,TensorFlow平方根函数的tf.sqrt()结果为InternalError。import tensorflow as tf# enable eager executiontf.enable_eager_execution()> tf.pow(2,4)'Out': <tf.Tensor: id=48, shape=(), dtype=int32, numpy=16>> tf.sqrt(4)>>> Traceback (most recent call last):  File "<ipython-input-21-5dc8e2f4780c>", line 1, in <module>    tf.sqrt(4)  File "/Users/ekababisong/anaconda3/envs/py36_dl/lib/python3.6/site-packages/     tensorflow/python/ops/math_ops.py", line 365, in sqrt         return gen_math_ops.sqrt(x, name=name)  File "/Users/ekababisong/anaconda3/envs/py36_dl/lib/python3.6/site-packages/     tensorflow/python/ops/gen_math_ops.py", line 7795, in sqrt        _six.raise_from(_core._status_to_exception(e.code, message), None)  File "<string>", line 3, in raise_fromInternalError: Could not find valid device for node name: "Sqrt"op: "Sqrt"input: "dummy_input"attr {  key: "T"  value {    type: DT_INT32  }} [Op:Sqrt] name: Sqrt/
查看完整描述

3 回答

?
慕妹3146593

TA贡献1820条经验 获得超9个赞

在这种情况下,值只是int,仅使用numpy可能是一个好主意。

如果您仍然想使用TensorFlow,可以这样做:

tf.math.sqrt(tf.convert_to_tensor(4, dtype='float32'))

或者

tf.sqrt(tf.convert_to_tensor(4, dtype='float32'))

TensorFlow 2上测试


查看完整回答
反对 回复 2021-05-25
  • 3 回答
  • 0 关注
  • 157 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号