Python ImportError:numpy.core.multiarray导入失败,无法加载本机TensorFlow运行时
我刚刚开始使用张量用python编写演示程序。 我是python的初学者。 我执行了命令: python./getStartWithTensor.py 但结果是 以下是我编写的代码:Python ImportError:numpy.core.multiarray导入失败,无法加载本机TensorFlow运行时,python,tensorflow,Python,Tensorflow,我刚刚开始使用张量用python编写演示程序。 我是python的初学者。 我执行了命令: python./getStartWithTensor.py 但结果是 以下是我编写的代码: import tensorflow as tf # Model parameters W = tf.Variable([.3], dtype=tf.float32) b = tf.Variable([-.3], dtype=tf.float32) # Model input and output x = tf.
import tensorflow as tf
# Model parameters
W = tf.Variable([.3], dtype=tf.float32)
b = tf.Variable([-.3], dtype=tf.float32)
# Model input and output
x = tf.placeholder(tf.float32)
linear_model = W*x + b
y = tf.placeholder(tf.float32)
# loss
loss = tf.reduce_sum(tf.square(linear_model - y)) # sum of the squares
# optimizer
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)
# training data
x_train = [1, 2, 3, 4]
y_train = [0, -1, -2, -3]
# training loop
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init) # reset values to wrong
for i in range(1000):
sess.run(train, {x: x_train, y: y_train})
# evaluate training accuracy
curr_W, curr_b, curr_loss = sess.run([W, b, loss], {x: x_train, y: y_train})
print("W: %s b: %s loss: %s"%(curr_W, curr_b, curr_loss))
我如何解决它?我不熟悉python和tensorflow。
谢谢。我在网上找不到
getStartWithTensor.py
,所以我假设这是您创建的文件?请从您的getStartWithTensor.py
中提供一个MWE,这会导致错误。@MrZ,我创建了该文件,从以下位置获得了引用: