【发布时间】:2017-02-24 11:08:11
【问题描述】:
我正在尝试让来自https://arxiv.org/pdf/1609.05473.pdf 的 SequenceGAN (https://github.com/LantaoYu/SeqGAN) 运行。
在修复了明显的错误后,比如用stack替换pack,它仍然没有运行,因为高速公路网络部分需要tf.nn.rnn_cell._linear函数:
# highway layer that borrowed from https://github.com/carpedm20/lstm-char-cnn-tensorflow
def highway(input_, size, layer_size=1, bias=-2, f=tf.nn.relu):
"""Highway Network (cf. http://arxiv.org/abs/1505.00387).
t = sigmoid(Wy + b)
z = t * g(Wy + b) + (1 - t) * y
where g is nonlinearity, t is transform gate, and (1 - t) is carry gate.
"""
output = input_
for idx in range(layer_size):
output = f(tf.nn.rnn_cell._linear(output, size, 0, scope='output_lin_%d' % idx)) #tf.contrib.layers.linear instad doesn't work either.
transform_gate = tf.sigmoid(tf.nn.rnn_cell._linear(input_, size, 0, scope='transform_lin_%d' % idx) + bias)
carry_gate = 1. - transform_gate
output = transform_gate * output + carry_gate * input_
return output
tf.nn.rnn_cell._linear 函数在 Tensorflow 1.0 或 0.12 中似乎不再存在,我不知道用什么替换它。我找不到任何新的实现,或者关于 tensorflow 的 github 或(不幸的是非常稀疏的)文档的任何信息。
有人知道这个功能的新挂件吗? 提前非常感谢!
【问题讨论】:
-
为什么 tf.contrib.layers.linear 不适合你?
-
tf1.8中还包含这个函数吗?
标签: python tensorflow neural-network