- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试构建一个 seq2seq 模型,我尝试遵循 Tensorflow 官方教程,但没有提到预处理步骤。我尝试在网上搜索,每个教程都是从模型开始,没有预处理步骤信息。
我需要一些有关 seq2seq 中涉及的预处理步骤的信息:
如果我有一个像这样的数据集:(使用index2word词汇编码后)
encoder [1, 2, 1, 3, 4] decoder [2, 3, 4]
encoder [2, 3, 4, 1] decoder [11, 3, 4, 5, 1, 22, 45, 1, 3, 42, 32, 65]
encoder [4, 5, 3, 11, 23, 1, 33, 44, 1, 3] decoder [4, 2, 3, 5]
encoder [44, 55] decoder [5, 6, 3, 2, 4, 22, 42, 11, 34]
encoder [1] decoder [55, 6, 3, 2, 4, 5, 6, 7, 7]
encoder [4, 2, 3, 4, 5] decoder [6, 5, 3, 5, 6, 7, 8, 2, 4, 5]
encoder [44, 2, 1, 22, 5, 3, 2] decoder [6, 5, 3, 4, 5, 6, 7]
encoder [55, 3, 1, 5, 1] decoder [5, 3, 2, 3, 4, 5]
encoder [14] decoder [5, 6, 7]
如果我将 5 作为批量大小,则第一批:
encoder [1, 2, 1, 3, 4] decoder [2, 3, 4]
encoder [2, 3, 4, 1] decoder [11, 3, 4, 5, 1, 22, 45, 1, 3, 42, 32, 65]
encoder [4, 5, 3, 11, 23, 1, 33, 44, 1, 3] decoder [4, 2, 3, 5]
encoder [44, 55] decoder [5, 6, 3, 2, 4, 22, 42, 11, 34]
encoder [1] decoder [55, 6, 3, 2, 4, 5, 6, 7, 7]
现在,在阅读了许多文章后,我发现有四个特殊的标记,您必须使用它们来编码数据:
<PAD>
: During training, we’ll need to feed our examples to the network in batches.
<EOS>
: This is another necessity of batching as well, but more on the decoder side. It allows us to tell the decoder where a sentence ends, and it allows the decoder to indicate the same thing in its outputs as well.
<UNK>
: replace unknown with .
<GO>
: This is the input to the first time step of the decoder to let the decoder know when to start generating output.
现在,如果我以我的批处理为例,那么我在填充后有问题:
编码器批处理应该与解码器批处理大小相同吗?
如果我的填充编码器数据批处理如下所示:
encoder_input=[[1, 2, 1, 3, 4],
[2, 3, 4, 1],
[4, 5, 3, 11, 23, 1, 33, 44, 1, 3],
[44, 55],
[1]]
#after padding ( max time stamp is 10 )
encoder_padded=[[1, 2, 1, 3, 4, 0, 0, 0, 0, 0],
[2, 3, 4, 1, 0, 0, 0, 0, 0, 0],
[4, 5, 3, 11, 23, 1, 33, 44, 1, 3],
[44, 55, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
现在我应该将解码器序列长度填充到相同的大小吗? (最大 10?)或者我应该用解码器最大序列(最大 12)填充,如下所示:
decoder_input=[[2, 3, 4],
[11, 3, 4, 5, 1, 22, 45, 1, 3, 42, 32, 65],
[4, 2, 3, 5],
[5, 6, 3, 2, 4, 22, 42, 11, 34],
[55, 6, 3, 2, 4, 5, 6, 7, 7]]
#after padding ( decoder batch max length is 12)
decoder_padded=[[2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[11, 3, 4, 5, 1, 22, 45, 1, 3, 42, 32, 65],
[4, 2, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0],
[5, 6, 3, 2, 4, 22, 42, 11, 0, 0, 0, 0],
[55, 6, 3, 2, 4, 5, 6, 7, 7, 0, 0, 0]]
以及我最后的预处理数据应该是什么样子:
encoder_input = ['hello','how','are','you','<PAD>','<PAD>','<PAD'>]
decoder_output = ['<GO>','i','am','fine','<EOS>','<PAD>','<PAD>']
这个格式正确吗?
最佳答案
我希望这有用。
should encoder batch should be same size to decoder batch ?
不,解码器计算跟随编码器,因此相应的数据将在不同的时间馈送到网络。你展示的例子是正确的。
上一个示例中的一个小修正,您提到的解码器输出应该是解码器输入。对于这对输入,您应该具有目标标签:
encoder_input = ['hello','how','are','you','<PAD>','<PAD>','<PAD'>]
decoder_input = ['<GO>','i','am','fine','<EOS>','<PAD>','<PAD>']
target_label = ['i','am','fine','<EOS>','<PAD>','<PAD>']
关于tensorflow - seq2seq模型的预处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51089903/
当我同时定义两条指令时,如何做到这一点,我会收到编译错误? 在这里我想要错误 #define ENG #define POL #if defined POL #if defined ENG 这里没有
我有actix-web,并且调试困难,因为记录器仅在最后写入,如果出现故障,则根本不会写入。RUST_LOG=actix_web=debug,actix_server=debug let server
对于以下有关数据预处理聚类的问题,我很困惑,在互联网上找不到令人信服的答案。 根据Python documentation ,当我们使用 sckit learn 库中的内置命令进行预处理时,假设数据被
我无法理解预处理器的工作原理以及 ## 在这个特定示例中代表什么 #include #define TEMP_KEY(type,Key) (TEMP_##type | Key) enum TEMPK
我一直在尝试对 Kaggle 上的 Sentiment140 数据库进行一些预处理:https://www.kaggle.com/kazanova/sentiment140 我使用的代码是这样的: i
例如,考虑在 Keras 中微调 Resnet50 模型。 For example here : from keras.applications.resnet50 import ResNet50 fr
我想预处理 JavaScript 属性名称以将其转换为 { 'extension': object, 'config': {id: 1} } 到 { extension: object,
我在编译 C 程序时在预处理步骤中遇到错误。 奇怪的是,我可以运行预处理而没有错误或警告: gcc -I/usr/local/libpng-1.6.24/include -Wall -std=c99
我很好奇 GCC 预处理步骤的输出。更准确地说,以下两行的目的是什么: # 1 "" # 1 "" 我知道格式是 但我不明白本节中可能会出现什么类型的数据。它的目的是什么? 谢谢! 最佳答案 目的是
我需要能够预处理多个 C# 文件作为项目的预构建步骤,检测方法的开始,并在方法开始处插入生成的代码,在任何现有代码之前。但是,我在检测方法的打开时遇到问题。我最初尝试了一个正则表达式来匹配,但最终出现
如何使用 C 预处理自动生成以下代码模式(访问器)? // Immutable accessor. const auto& member1 () const { return _member1;
我正在考虑分两个阶段实现 C 预处理器,其中第一阶段将源文件转换为预处理标记数组。这对于简单性和性能都有好处,因为当项目中的多个文件包含头文件时,不需要重做标记化工作。 障碍: #define f(x
有没有办法“预处理”C99 样式的二合字母以获得 C 文件(或 .i 预处理源),使得生成的文件不包含任何二合字母? 例如,给出以下源代码: %:define N 5 int main() = ;
如何使用 browserify 预处理函数调用? 在一个大的 js 文件中,有时我需要将一个 JSON 对象传递给一个变量,但这个 JSON 对象只能通过函数调用创建: var myvar = Rac
我正在对电视镜头中的字幕应用 OCR。 (我正在使用带 C++ 的 Tesseact 3.x)我正在尝试拆分文本和背景部分作为 OCR 的预处理。 这是原图: 然后,预处理图像: OCR结果为:Sic
我正在开发一个函数,该函数采用众所周知的参数范围,但我不想为每种情况编写许多不同的函数。有没有一种方法可以定义函数的“模式”并使预编译器根据这种模式生成函数? 例子。我有以下功能: int addit
我有一个包含多个脚本标签(接近 20 个)的 html 文件。我决定将所有 JS 文件连接成一个文件,然后缩小连接后的文件。我正在使用 ant 任务来连接并将这样做以进行缩小。我知道我需要提供非串联/
我想在 AngularJS 更新任何 HTML 之前添加一个预处理步骤。为了简单起见,让我们将 hello 的所有实例都加粗。 . 也就是说,如果我们让$scope.text = "hello wor
我正在使用 tess4j 作为来自 JAVA 的 tesseract 的包装器对图像运行一系列 OCR。 ocr 的过程仍然需要大量时间(有时甚至 5 秒),我正在努力加快它的速度。 我正在对图像进行
我一直在阅读有关 Phing 和 Ant 的文章,但我不确定这些工具中哪一个(如果有的话)对这种情况最有用。 它很容易是调试语句等,但我会给你我们的字面扫描。 我们有一个可下载的 PHP 应用程序的免
我是一名优秀的程序员,十分优秀!