在哪里可以找到指定RNN和Seq2Seq模型中可用函数的API引用。
在github页面中提到,rnn和seq2seq已移至tf.nn
发布于 2016-05-18 02:18:50
注意:此答案已针对r1.0进行了更新...,但解释的是legacy_seq2seq而不是tensorflow/tensorflow/contrib/seq2seq/
好消息是,tensorflow中提供的seq2seq模型相当复杂,包括嵌入、存储桶、注意力机制、一对多多任务模型等。
坏消息是,Python代码中有许多复杂性和抽象层,并且代码本身是最好的可用的更高级别的RNN和seq2seq "API“的”文档“,就我所能提供的代码是很好的docstring'd。
实际上,我认为下面提到的示例和助手函数主要用于参考,以便理解在大多数情况下需要使用低级Python API中的基本函数重新实现的patterns...and编码
下面是r1.0版本中RNN seq2seq代码的自上而下的分解:
...provides main()、train()、decode()开箱即用将英语转换为french...but您可以将此代码改编为其他数据集
...class Seq2SeqModel()建立了一个复杂的mechanism...if编码器-解码器与嵌入,桶,注意力mechanism...if你不需要嵌入,桶,或注意力你将需要实现一个类似的类.
通过帮助器函数实现seq2seq模型的...main入口点。参见model_with_buckets()、embedding_attention_seq2seq()、embedding_attention_decoder()、attention_decoder()、sequence_loss()等。示例包括one2many_rnn_seq2seq和没有嵌入/注意的模型,这些模型也像basic_rnn_seq2seq一样提供。如果你能把你的数据塞进这些函数可以接受的张量中,这可能是你构建自己模型的最佳切入点。
...provides是像static_rnn()这样的RNN网络的包装器,带有一些我通常不需要的铃声和口哨,所以我只需使用如下代码:
def simple_rnn(cell, inputs, dtype, score):
with variable_scope.variable_scope(scope or "simple_RNN") as varscope1:
if varscope1.caching_device is None:
varscope1.set_caching_device(lambda op: op.device)
batch_size = array_ops.shape(inputs[0])[0]
outputs = []
state = cell.zero_state(batch_size, dtype)
for time, input_t in enumerate(inputs):
if time > 0:
variable_scope.get_variable_scope().reuse_variables()
(output, state) = cell(input_t, state)
outputs.append(output)
return outputs, state发布于 2016-05-12 12:19:43
到目前为止,我在他们的网站上也找不到关于rnn函数的API参考。
然而,我相信你可以在github上看到每个函数的注释作为函数引用。
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/rnn.py
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/rnn_cell.py
发布于 2016-09-14 12:24:17
TensorFlow当前/主版本的RNN文档:https://www.tensorflow.org/versions/master/api_docs/python/nn.html#recurrent-neural-networks
针对特定版本的TensorFlow的RNN文档:https://www.tensorflow.org/versions/r0.10/api_docs/python/nn.html#recurrent-neural-networks
对于好奇的人,这里有一些关于为什么RNN文档最初不可用的注释:API docs does not list RNNs
https://stackoverflow.com/questions/37159372
复制相似问题