![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch学习
文章平均质量分 78
Brikie
这个作者很懒,什么都没留下…
展开
-
pytorch几种损失函数CrossEntropyLoss、NLLLoss、BCELoss、BCEWithLogitsLoss、focal_loss、heatmap_loss
分类问题常用的几种损失,记录下来备忘,后续不断完善。nn.CrossEntropyLoss()交叉熵损失常用于多分类问题CE = nn.CrossEntropyLoss()loss = CE(input,target)Input: (N, C) , dtype: float, N是样本数量,在批次计算时通常就是batch_sizetarget: (N), dtype: long,是类别号,0 ≤ targets[i] ≤ C−1pytorch中的交叉熵损失就是softmax和NLL损失的组合原创 2021-04-26 21:08:54 · 4067 阅读 · 1 评论 -
pytorch autograd整理
网上有不少介绍这个的,我再自己整理一遍以加强理解,便于以后查阅。原创 2021-04-02 16:23:57 · 445 阅读 · 0 评论 -
pytorch版 RGB_to_HSV和HSV_to_RGB
pytorch实现图像RGB和HSV色彩空间的相互转换,可直接加入神经网络中,支持反向传播,支持cuda。原创 2021-03-22 17:53:32 · 4392 阅读 · 5 评论 -
【pytorch学习】四种钩子方法(register_forward_hook等)的用法和注意点
为了节省显存(内存),pytorch在计算过程中不保存中间变量,包括中间层的特征图和非叶子张量的梯度等。有时对网络进行分析时需要查看或修改这些中间变量,此时就需要注册一个钩子(hook)来导出需要的中间变量。网上介绍这个的有不少,但我看了一圈,多少都有不准确或不易懂的地方,我这里再系统总结一下。hook方法有四种:torch.Tensor.register_hook()torch.nn.Module.register_forward_hook()torch.nn.Module.register_原创 2021-03-01 18:20:34 · 17310 阅读 · 2 评论 -
Pytorch CookBook
结合网上收集和个人总结,用于以后背记。检查 PyTorch 版本:torch.__version__ # PyTorch versiontorch.version.cuda # Corresponding CUDA versiontorch.backends.cudnn.version() # Corresponding cuDNN versiontorch.cuda.get_device_name(0) # GPU t原创 2021-02-02 22:20:17 · 215 阅读 · 0 评论