小编Tho*_*ani的帖子

使用Tensorflow与RNN和批处理规范化

我一直在Tensorflow中跟踪SEGFAULT。可以使用以下代码段重现该问题:

import tensorflow as tf                                                                                                                                                                                                                       

with tf.device('/cpu:0'):
    xin = tf.placeholder(tf.float32, [None, 1, 1], name='input')
    rnn_cell = tf.contrib.rnn.LSTMCell(1)
    out, _ = tf.nn.dynamic_rnn(rnn_cell, xin, dtype=tf.float32)
    out = tf.layers.batch_normalization(out, training=True)
    out = tf.identity(out, name='output')

    optimiser = tf.train.AdamOptimizer(.0001)
    update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
    with tf.control_dependencies(update_ops):
        out = optimiser.minimize(out, global_step=tf.Variable(0, dtype=tf.float32), name='train_op')

config = tf.ConfigProto(allow_soft_placement = False)
sess = tf.Session(config=config)
sess.run(tf.global_variables_initializer())

sample_in = [[[0]]]
sess.run(out, feed_dict={xin: sample_in})
Run Code Online (Sandbox Code Playgroud)

我设法找到了这个问题,并在github上有一个pull-request请求。如果使用我的补丁程序运行此代码,则会收到以下错误消息:

2018-04-03 13:09:24.326950: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1212] Found device 0 with properties:                                                                                                                          
name: TITAN Xp major: 6 minor: …
Run Code Online (Sandbox Code Playgroud)

python tensorflow batch-normalization tensorflow-xla rnn

5
推荐指数
0
解决办法
638
查看次数