- 博客(4)
- 收藏
- 关注
原创 Pytorch交叉熵损失的理解
Pytorch交叉熵损失的理解# 让我们康康这个小栗子>>> input = torch.randn(3, 5, requires_grad=True) # 定义输入(可看成是神经网络最后一层的输出),需要梯度信息以被更新>>> target = torch.randint(5, (3,), dtype=torch.int64) # 定义交叉熵类别>>> optimizer = torch.optim.Adam([input],lr=1)
2020-09-12 09:23:58
323
原创 scipy库的csr_matrix和csc_matrix
scipy库中的csr_matrix和csc_matrixfrom scipy.sparse import csr_matrixfrom scipy.sparse import csc_matriximport numpy as np>>> indptr = np.array([0, 2, 3, 6])>>> indices = np.array([0, 2, 2, 0, 1, 2])>>> data = np.array([1, 2, 3
2020-09-05 16:56:36
291
转载 转载:离散分布随机取样方法:Alias Method
声明:本文转载自http://shomy.top/2017/05/09/alias-method-sampling/感谢作者 天空的城!在图的随机游走中,有一块需要随机取样, 比如当前到达v节点,那么下一次随机会到达哪个节点。这种问题其实就是离散分布的随机变量的取样问题。 查了一些资料, 发现Alias Method 是一种很高效的方式。在初始好之后,每次取样的复杂度为O(1)O(1)O(1)。最大的好处就是构造好ProbProbProb和AliasAliasAlias数组后,就能高效采样。 下面介绍下
2020-09-04 19:10:06
1090
1
原创 Ubuntu18中,使用Python的matplotlib库设置simhei.ttf中文字体并显示
Ubuntu18中,使用Python的matplotlib库设置simhei.ttf中文字体并显示首先,下载中文字体simhei.ttf其次,需要知道当前使用的matplotlib库的环境配置即使用语句:import matplotlibprint(matplotlib.matplotlib_fname())可得:可以推测出matplotlib的字体文件就在mpl-data/文件夹下的fonts/ttf/文件夹下。即路径:/home/peter/anaconda3/envs/py3torch
2020-09-04 17:59:29
7503
3
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人