在运行pointer-generator代码时出现了如下报错:
WARNING:tensorflow:From/home/shirveon/env/local/lib/python2.7/site-packages/tensorflow/python/util/tf_should_use.py:170: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use `tf.global_variables_initializer` instead.
WARNING:tensorflow:From run_summarization.py:116: all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Please use tf.global_variables instead.
根据报错信息我将代码中tf.all_variables替换成tf.global_variables,tf.initial_all_variables替换成tf.global_variables,成功解决了这个问题。
tf.global_variables或者tf.all_variables的功能均为获取程序中的变量,不同的版本是不同的,目前的tensorflow多用前一个函数,返回的值是变量的一个列表。
import tensorflow as tf
import numpy as np
v = tf.Variables(tf.constant(0.0, shape =[1],dtype = tf.float32), name = 'v')
v1 = tf.Variable(tf.constant(5, shape = [1], dtype = tf.tloat32,), name='v1')
variables = tf.global_variables()
print(variables[0].name)
print(variables[1].name)
#v:0
#v1:0