![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch
文章平均质量分 51
zyoung17
这个作者很懒,什么都没留下…
展开
-
torch.Tensor.index_add_函数,pytorch中的tf.unsorted_segment_sum
ref:https://pytorch.org/docs/1.4.0/tensors.html?highlight=index_add_#torch.Tensor.index_add_https://blog.csdn.net/weixin_44289071/article/details/103882658torch.Tensor.index_add_能实现指定行或列的内容相加的功能,类似于tensorflow中tf.unsorted_segment_sum函数,可以用在比如实例分割中进行特征聚原创 2021-05-10 11:48:59 · 5600 阅读 · 2 评论 -
pytorch中的top_K()函数
pytorch中的top_K()函数https://www.jb51.net/article/177713.htm转载 2021-04-16 16:48:30 · 372 阅读 · 0 评论 -
Pytorch中Tensorboard的使用
SummaryWriter类主要使用SummaryWriter类来进行变量的保存,它可以向指定的文件夹写入事件文件,这个事件文件可以被tensorboard读取。这个类需要传入的主要参数为log_dir和comment,前者设定事件文件的保存路径,后者可以在文件夹名称后添加一些备注,如学习率、batch_size等做一个区分。保存需要可视化的事件文件主要涉及的函数为.add_scalar(),通过这个函数可以传入图片的名称,纵轴数据以及横轴数据。对应的参数名分别为tag、scalar_valu原创 2020-09-24 16:43:40 · 2199 阅读 · 0 评论 -
PyTorch损失函数之交叉熵损失函数nn.CrossEntropyLoss()
PyTorch之nn.CrossEntropyLoss()nn.CrossEntropyLoss()是nn.logSoftmax()和nn.NLLLoss()的整合,可以直接使用它来替换网络中的这两个操作,这个函数可以用于多分类问题。具体的计算过程可以参考官网的公式或者一下这个链接。https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html#torch.nn.CrossEntropyLosshttps://blog.原创 2020-09-06 13:41:26 · 27953 阅读 · 9 评论 -
torch.gather在求单分类任务交叉熵损失时的用法
torch.gather()的用法参考链接:TORCH.GATHER函数参数:输入一个源tensor以及需要对齐的索引以及对齐的维度,返回对齐的结果。例子:import torcht = torch.tensor([[1,2],[3,4]])out = torch.gather(t, 1, torch.tensor([[0,0],[1,0]]))print(out)output:tensor([[1, 1], [4, 3]])需要注意的是输入的索引的维度和tenso.原创 2020-09-01 15:07:30 · 563 阅读 · 0 评论 -
安装Pytorch
在Windows环境下安装PyTorch安装anaconda,参照链接Anaconda入门按照路径Start | Anaconda3 | Anaconda Prompt打开windows下的终端框。将pytorch安装在对应的虚拟环境中便于管理,使用如下命令创建虚拟环境并进入环境。也可以使用Anaconda软件的图形化界面来创建虚拟环境。conda create -n torch py...原创 2019-12-09 19:54:06 · 472 阅读 · 0 评论