- 博客(29)
- 收藏
- 关注
原创 关于Pytorch的create_graph和retain_graph的一点小得
当我们想求二阶导时,用autograd.grad是执行了一次前向运算,但该函数默认不会保存计算图,因此并没有求导运算的过程,无法再继续用结果求二阶导。首先我们要搞清一个逻辑,就是在Pytorch中,张量间的计算产生计算图,而反向传递会导致计算图删除(反向即backward()函数,请注意,用autograd求导不会导致计算图被删除)。此外,retain_graph是retain当前的式子的计算图,当我们不想让backward()函数释放掉当前计算图时,我们可以使用retain_graph=True。
2023-07-21 21:39:10
931
原创 Leetcode Hot100|121. 买卖股票的最佳时机 Python
Leetcode Hot100|121. 买卖股票的最佳时机 Python
2022-10-30 10:54:07
740
原创 Leetcode Hot100|114. 二叉树展开为链表 Python
Leetcode Hot100|114. 二叉树展开为链表 Python
2022-10-29 19:14:38
667
原创 CUDA报错:Out of Memory
RuntimeError: CUDA out of memory. Tried to allocate xx GiB (GPU 0; xx GiB total capacity; xx GiB already allocated; xx GiB free; xx GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid
2022-10-28 17:20:04
12352
6
原创 Leetcode Hot100|105. 从前序与中序遍历序列构造二叉树 Python
Leetcode Hot100|105. 从前序与中序遍历序列构造二叉树 Python
2022-10-28 11:03:39
500
原创 Leetcode Hot100|102. 二叉树的层序遍历 Python
Leetcode Hot100|102. 二叉树的层序遍历 Python
2022-10-27 10:20:49
1341
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人