![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
每天一个写bug小技巧
bald
在读研究生,只是做一些微小的记录。
展开
-
nll loss 和CrossEntropyLoss 的一些区别
NLL Loss在传入这个loss前,需要先对输入进行一次 log_softmax 的变换, 例子如下:import torchimport torch.nn as nnimport torch.nn.functional as Fseed=1m = nn.LogSoftmax(dim=1)loss = nn.NLLLoss()# input is of size N x C = 3 x 5input = torch.randn(3, 5, requires_grad=True)pri原创 2020-12-28 19:04:34 · 1558 阅读 · 0 评论 -
mac 安装 pytorch_geometric ‘gcc‘ failed with exit status 1
遇到了官网提到的问题9:On macOS: ‘gcc’ failed with exit status 1: Install the respective packages by using the following environment variables (see Issue#21):MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install然而这个命令是不对的,去看Issus#21提到的解决方案第一原创 2020-12-09 10:19:57 · 313 阅读 · 0 评论 -
Latex figure 引用显示错误
在latex中插入图片后,引用发现,不显示标号或者是标号显示错误, 我遇到的是:明明写了引用:\ref{fig:1}\ref{fig:2}是不一样的,但是在 PDF 中,显示的是相同的 数字, 都是 Figure 1。一般是因为 \caption 和 \label 的相对未知不对。记住:\label 一定要放在 \caption 后面。参考...原创 2020-04-22 16:28:11 · 2722 阅读 · 1 评论 -
RuntimeError: expected device cpu but got device cuda:0 --每天一个写 bug 小技巧
这是一个综合 debug 方法:不管是 expected cpu 还是 expected cuda, 本质原因都是类型不匹配。一般是因为:等号左边和右边类型不一样运算符左右两端类型不同同一个函数内,传入参数类型不同,比如 mutual...原创 2020-04-30 15:46:55 · 5298 阅读 · 4 评论 -
latex 公式编辑方法
各种数学符号期望E\mathbb{E}公式1. 对齐\begin{align*} f(x) &= (x+a)(x+b) \\ &= x^2 + (a+b)x + ab\end{align*}原创 2019-09-19 13:34:12 · 1174 阅读 · 0 评论 -
cpp 超常用tips! -- 每天一个写bug小技巧
c++ map 相当于python 中的dict, 一个关键词对应一个值(multimap可以对应多个值)map默认是排好序的,如果有需要用到排序的对,那么可以创建map来维护数据结构。那么如果要取根据关键词(key)排序的元素的最后一位应该怎么做呢:取最后一位元素参考auto iter = my_map.crbegin();...原创 2019-09-11 12:23:17 · 668 阅读 · 0 评论 -
Latex学习笔记 -- 每天一个写 bug 小技巧
引用一般的latex模板会提供以.bst 结尾的文件,可以理解为bib style, 另外还有一个以.bib 结尾的文件, 比如现在我有两个文件 style.bst 和 cite.bib要完成引用只需在\end{document} 前加两行即可:\bibliographystyle{style}\bibliography{cite}...原创 2019-08-22 19:03:52 · 172 阅读 · 0 评论