需要有关tensorflow_addons对象的更多信息

问题描述

我正在尝试使用带有张量流的注意力机制构建编码器-解码器模型。 我正在使用tensorflow_addons存储库,试图重现和理解此模型:https://www.tensorflow.org/addons/tutorials/networks_seq2seq_nmt

很遗憾,BasicDecoderSamplerAttentionWrapper对象上没有足够的文档供我完美使用。在研究期间,我能找到的最明确的文档是https://medium.com/@dhirensk/tensorflow-addons-seq2seq-example-using-attention-and-beam-search-9f463b58bc6b

最模糊的阶段是使用TrainingSampler()GreedyEmbeddingSampler()时,但他没有更深入地了解采样器的上下文,我唯一需要了解的信息是在{ {3}}:

#Sampler instances are used by BasicDecoder. The normal usage of a sampler is like below:

sampler = Sampler(init_args)
(initial_finished,initial_inputs) = sampler.initialize(input_tensors)
cell_input = initial_inputs
cell_state = cell.get_initial_state(...)
for time_step in tf.range(max_output_length):
    cell_output,cell_state = cell(cell_input,cell_state)
    sample_ids = sampler.sample(time_step,cell_output,cell_state)
    (finished,cell_input,cell_state) = sampler.next_inputs(
        time_step,cell_state,sample_ids)
    if tf.reduce_all(finished):
        break

此外,我的模型不包含嵌入层,因为我的输入向量不需要它。因此,我想在测试/推断期间必须使用另一个采样器代替GreedyEmbeddingSampler()。

我希望我足够清楚,希望有人可以帮助我理解。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)