我正在使用 tensorflow 1.1.0 来运行用以前版本的 tensorflow 编写的代码。它包括这部分:
cell = tf.contrib.rnn.LSTMCell(num_units=64, state_is_tuple=True)
outputs, last_states = tf.nn.dynamic_rnn(
cell=cell,
dtype=tf.float64,
sequence_length=X_lengths,
inputs=X)
result = tf.contrib.learn.run_n(
{"outputs": outputs, "last_states": last_states},
n=1,
feed_dict=None)
我收到以下警告:
WARNING:tensorflow:From tensorflow/contrib/learn/python/learn/graph_actions.py:900: run_feeds_iter (from tensorflow.contrib.learn.python.learn.graph_actions) is deprecated and will be removed after 2017-02-15.
Instructions for updating:
graph_actions.py will be deleted. Use tf.train.* utilities instead. You can use learn/estimators/estimator.py as an example.
我在 tensroflow 1.0+ 中找不到 tf.contrib.learn.run_n 的替代品。有没有我可以使用的替代函数?
请您参考如下方法:
我不确定是否有一个函数可以直接替代有问题的函数。以下替代方案应该可以在没有警告的情况下工作:
n_iter = 1
result = []
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for i in range(n_iter):
result_ = sess.run({'outputs': outputs, 'last_states':last_states}, feed_dict=None)
result.append(result_)
