循环神经网络
hihi
爱飞的企鹅
这个作者很懒,什么都没留下…
展开
-
语言模型和数据集
1.自然语言统计import randomimport torchfrom d2l import torch as d2ltokens = d2l.tokenize(d2l.read_time_machine())# 因为每个文本行不一定是一个句子或一个段落,因此我们把所有文本行拼接到一起corpus = [token for line in tokens for token in line]corpus['the', 'time', 'machine', 'by', 'h',原创 2022-05-23 20:40:29 · 415 阅读 · 1 评论 -
31. 文本预处理
文本预处理将文本作为字符串加载到内存中将字符串拆分为词元(如单词和字符)建立一个词汇表,将拆分的词元映射到数字索引将文本转换为数字索引序列,方便模型操作1.读取数据集import collectionsimport refrom d2l import torch as d2ld2l.DATA_HUB['time_machine'] = (d2l.DATA_URL + 'timemachine.txt', '090b5e7原创 2022-05-23 18:34:58 · 267 阅读 · 0 评论 -
动手学深度学习---序列模型
%matplotlib inlineimport torchfrom torch import nnfrom d2l import torch as d2lT = 1000 # 总共产生1000个点time = torch.arange(1,T+1,dtype = torch.float32)x = torch.sin(0.01*time) + torch.normal(0,0.2,(T,))d2l.plot(time, [x], 'time', 'x', xlim=[1, 1000],原创 2022-05-23 02:29:42 · 392 阅读 · 0 评论