Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tensorflow 1.11挂起;sess=tf.Session();_Python_Tensorflow - Fatal编程技术网

Python Tensorflow 1.11挂起;sess=tf.Session();

Python Tensorflow 1.11挂起;sess=tf.Session();,python,tensorflow,Python,Tensorflow,我从1.10更新到TensorFlow 1.11,无法运行运行状况检查。下面的代码挂起sess=tf.Session() 配置:Windows10x64,最新的GPU驱动程序,CUDA9.0,CUDNN7.3,Python 3.6.6。同样的设置也适用于TF1.10,突然一切都停止了 还有其他人遇到过类似的情况吗 import os import numpy as np import tensorflow as tf def tftest(a, b): # Create 100 pho

我从1.10更新到TensorFlow 1.11,无法运行运行状况检查。下面的代码挂起
sess=tf.Session()

配置:Windows10x64,最新的GPU驱动程序,CUDA9.0,CUDNN7.3,Python 3.6.6。同样的设置也适用于TF1.10,突然一切都停止了

还有其他人遇到过类似的情况吗

import os
import numpy as np
import tensorflow as tf

def tftest(a, b):
    # Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
    x_data = np.random.rand(100).astype(np.float32)
    y_data = x_data * a + b

    # Try to find values for W and b that compute y_data = W * x_data + b
    # (We know that W should be 0.1 and b 0.3, but TensorFlow will
    # figure that out for us.)
    W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
    b = tf.Variable(tf.zeros([1]))
    y = W * x_data + b

    # Minimize the mean squared errors.
    loss = tf.reduce_mean(tf.square(y - y_data))
    optimizer = tf.train.GradientDescentOptimizer(0.5)
    train = optimizer.minimize(loss)

    # Before starting, initialize the variables.  We will 'run' this first.
    init = tf.global_variables_initializer()

    # Launch the graph.
    sess = tf.Session()   #<< the script hangs here!
    sess.run(init)

    # Fit the line.
    for step in range(201):
        sess.run(train)
        if step % 20 == 0:
            print(step, sess.run(W), sess.run(b))

if __name__ == "__main__":
    tftest(20, 10)
导入操作系统
将numpy作为np导入
导入tensorflow作为tf
def tftest(a,b):
#在NumPy中创建100个假x,y数据点,y=x*0.1+0.3
x_data=np.random.rand(100).astype(np.float32)
y_数据=x_数据*a+b
#尝试查找计算y_data=W*x_data+b的W和b的值
#(我们知道W应该是0.1,b应该是0.3,但TensorFlow会
#为我们找出答案。)
W=tf.变量(tf.随机统一([1],-1.0,1.0))
b=tf.变量(tf.零([1]))
y=W*x_数据+b
#最小化均方误差。
损失=tf.减少平均值(tf.平方(y-y_数据))
优化器=tf.train.GradientDescentOptimizer(0.5)
列车=优化器。最小化(损失)
#在开始之前,初始化变量。我们将首先“运行”这个。
init=tf.global_variables_initializer()
#启动图表。
sess=tf.Session()#我想这是一个好主意。该问题仍然存在,似乎与使用MSVC构建的Egen中的一个问题有关

好消息是TensorFlow不会无限期挂起:必须等待3-4-5分钟,然后代码恢复。这只在TensorFlow第一次启动时发生一次