本文记录学习下面三个任务过程中思考过的问题及大家讨论过程中学习到的知识点,欢迎指正。
- 文本预处理
- 语言模型
- rnn
基础知识部分直接参考Dive-into-DL-PyTorch
ngram的缺点以及如何解决
gram模型的缺点:
参数系数,参数空间过大,存储和内存吃不消
参数空间过大
数据稀疏
但如何解决上述问题,只需要加入平滑方法,如
Additive smoothing
Good-Turing estimate
Jelinek-Mercer smoothing (interpolation)
Katz smoothing (backoff)
Witten-Bell smoothing
Absolute discounting
Kneser-Ney smoothing (常用)
具体细节可以参考 Speech and Language Processing
如何可视化理解序列模型的采样
原文
比如 给定训练数据[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],批量大小为batch_size=2,时间步数为2,则resize成[0, 1, 2, 3, 4]和[5, 6, 7, 8, 9],则第一个batch为[[0, 1],[5, 6]];第二个batch为[[2, 3],[7, 8]]
所以便很好代码逻辑
def data_iter_consecutive(corpus_indices, batch_size, num_steps, device=None):
if device is None:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
corpus_len = len