在 tensorflow 1.0+ 中替换 tf.contrib.learn.run_n [英] Replacement of tf.contrib.learn.run_n in tensorflow 1.0+

查看:25
本文介绍了在 tensorflow 1.0+ 中替换 tf.contrib.learn.run_n的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 tensorflow 1.1.0 来运行用之前版本的 tensorflow 编写的代码.它包括这部分:

I am using tensorflow 1.1.0 to run a code that is written with prior versions of tensorflow. It includes this part:

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 的替代品.有没有我可以使用的替代功能?

I couldn't find the replacement of tf.contrib.learn.run_n in tensroflow 1.0+. Is there an alternative function that I can use instead?

推荐答案

我不确定是否有一个函数可以直接替代有问题的函数.以下替代方案应该可以在没有警告的情况下工作:

I am not sure whether there is one function that can directly substitute the function in question. The following alternative should work without warnings:

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_)

这篇关于在 tensorflow 1.0+ 中替换 tf.contrib.learn.run_n的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆