2017-03-04 62 views

回答

1

我的建议是确保你的会话知道它在哪个图上运行。 出头,你可以尝试是:

  1. 构建图形第一,并通过在图形中的会话。

    myGraph = tf.Graph() 
    with myGraph.as_default(): 
        # build your graph here 
    
    mySession = tf.Session(graph=myGraph) 
    mySession.run(...) 
    
    # Or 
    
    with tf.Session(graph=myGraph) as mySession: 
        mySession.run(...) 
    
  2. 如果你想使用多个with声明,以嵌套的方式来使用它。

    with tf.Graph().as_default(): 
        # build your graph here 
        with tf.Session() as mySession: 
         mySession.run(...)