pytorch学习笔记
文章平均质量分 62
transformer_WSZ
You Only Look Once!
展开
-
A BetterTransformer for Fast Transformer Inference
PyTorch 1.12版本对进行了专项优化,用户无须调整模型结构即可大幅提升Transformer推理性能。具体介绍如下:more。翻译 2022-10-10 00:28:27 · 447 阅读 · 0 评论 -
DataLoader中sampler参数介绍
DataLoader | Sampler | DataSet 关系Sampler : 提供数据集中元素的索引DataSet : 根据 Sampler 提供的索引来检索数据DataLoader : 批量加载数据用于后续的训练和测试Samplerclass Sampler(object): r"""Base class for all Samplers. Every Sampler subclass has to provide an __iter__ method, provi原创 2021-12-24 01:59:34 · 3748 阅读 · 0 评论 -
深度学习代码编写及调参经验
数据预处理好之后可以保存成pkl文件,这样后面多次运行程序的时候,可以直接加载。省的每次都要处理浪费时间tag2id 列完之后可以用一行代码转换成 id2tag:id2tag = {num: label for label, num in tag2id.items()}...原创 2021-12-21 21:30:23 · 671 阅读 · 0 评论 -
pytorch中的二分类及多分类交叉熵损失函数
本文主要记录一下pytorch里面的二分类及多分类交叉熵损失函数的使用。import torchimport torch.nn as nnimport torch.nn.functional as Ftorch.manual_seed(2020)<torch._C.Generator at 0x7f4e8b3298b0>二分类交叉熵损失函数Singlem = nn.Sigmoid()loss = nn.BCELoss()input = torch.randn(3, re原创 2020-11-12 23:42:57 · 16852 阅读 · 2 评论 -
expand 和 repeat 区别
expand()Returns a new view of the :attr:self tensor with singleton dimensions expanded to a larger size.将张量=1的维度进行扩展,>1的维度保持不变。import torcha = torch.tensor([[12, 3, 4]])a.expand(3,-1)tensor([[12, 3, 4], [12, 3, 4], [12, 3,原创 2020-08-12 21:55:21 · 323 阅读 · 0 评论