pytorch
纵浪大化中,喜,惧
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
pytorch交叉熵损失函数研究
使用这个损失函数可以很方便的避免上溢和下溢 nn.CrossEntropyLoss()官方文档 自己写的代码: def cross_entropy(y_hat=torch.tensor(0), y=torch.tensor(0)): numerator = y_hat[range(len(y_hat)),y] denominator = torch.log(torch.sum(torch.exp(y_hat),1)) l = -numerator+denominator .原创 2021-11-22 21:06:31 · 863 阅读 · 0 评论 -
softmax分类
参数初始化也很重要 学习了zip,enumerate用法 pytorch的广播机制 import torch import torchvision from torch.utils import data from torchvision import transforms from utils import * W = torch.normal(0, 1, (784, 10), requires_grad=True) b = torch.zeros(10, requires_grad=True) bat原创 2021-11-22 16:40:04 · 740 阅读 · 0 评论 -
pytorch广播机制
和numpy一样 可以进行广播的条件: 1Each tensor has at least one dimension. 2When iterating over the dimension sizes, starting at the trailing dimension(从右向左), the dimension sizes must either be equal, one of them is 1, or one of them does not exist. 怎么广播? dimensions wi原创 2021-11-21 16:04:20 · 401 阅读 · 0 评论
分享