【问题标题】:How can i handle python code with tensorflow我如何使用 tensorflow 处理 python 代码
【发布时间】:2020-02-13 13:26:13
【问题描述】:
import tensorflow as tf

intNum1 = int(input("enter num 1: "))
intNum2 = int(input("enter num 2: "))

num1 = tf.Variable(intNum1)
num2 = tf.Variable(intNum2)

sum = tf.add(num1, num2)

print("sum = " + str(sum))

globalVarsInitializer = tf.global_variables_initializer()

with tf.Session() as sess:
  globalVarsInitializer.run()
  result = sum.eval()

print("result = " + str(result))

我成功安装了 tensorflow 2,但是当我运行 python 代码时,我看到这些行并且我的代码不起作用

【问题讨论】:

  • 我建议使用 sys 验证 tensorflow 是否安装在您用于此代码的 python 环境中,或者如果您使用 conda,请检查 conda list

标签: python python-3.x tensorflow


【解决方案1】:

您在 CUDA 和/或 CuDNN 依赖项方面存在一些问题。确保您关注GPU installation guide

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-26
    • 2017-09-17
    • 1970-01-01
    • 2017-06-22
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    • 2013-08-11
    相关资源
    最近更新 更多