实战:生成图片文本摘要
发布时间
阅读量:
阅读量
上篇文章已经阐述了 Transformer 的基本原理。今天我们将基于论文内容编写一个 Transformer 模型,并用于之前的机器翻译案例分析。如果有兴趣的话,还可以作为练习进行对比分析。
这部分的数据内容与前文所述的机器翻译案例具有相似性。该英语—法语的数据集来源于ManyThings.org平台,并在其中选取了总共20个样本以保持简洁性。鉴于样本数量有限,在保证基本功能的前提下进行了必要的简化处理,并对论文中所设定的一些关键参数值,则采取了更为简化的处理方式。
准备数据
import tensorflow as tf
import numpy as np
import unicodedata
import re
import time
import matplotlib.pyplot as plt
raw_data = (
('What a ridiculous concept!', 'Quel concept ridicule !'),
('Your idea is not entirely crazy.', "Votre idée n'est pa
全部评论 (0)
还没有任何评论哟~
