打赏

随笔分类 -  pytorch

摘要:PyTorch Hook¶ 为什么要引入hook? -> hook可以做什么? 都有哪些hook? 如何使用hook? 1. 为什么引入hook?¶ 参考:Pytorch中autograd以及hook函数详解 在pytorch中的自动求梯度机制(Autograd mechanics)中,如果将ten 阅读全文
posted @ 2019-07-18 15:21 listenviolet 阅读(2691) 评论(0) 推荐(0)
摘要:如何在pytorch中使用自定义的激活函数? 如果自定义的激活函数是可导的,那么可以直接写一个python function来定义并调用,因为pytorch的autograd会自动对其求导。 如果自定义的激活函数不是可导的,比如类似于ReLU的分段可导的函数,需要写一个继承torch.autogra 阅读全文
posted @ 2019-07-17 15:53 listenviolet 阅读(8414) 评论(0) 推荐(0)
摘要:Iterators 对torchtext的batch实现的修改算法原理 Batching matters a ton for speed. We want to have very evenly divided batches, with absolutely minimal padding. To 阅读全文
posted @ 2019-05-24 20:11 listenviolet 阅读(545) 评论(0) 推荐(0)
摘要:1. RuntimeError: "exp" not implemented for 'torch.LongTensor' class PositionalEncoding(nn.Module) 将 “0” 改为 “0.” 否则会报错:RuntimeError: "exp" not implemen 阅读全文
posted @ 2019-05-22 22:31 listenviolet 阅读(6447) 评论(16) 推荐(1)
摘要:1. 为网络的不同部分指定不同的学习率 这里LeNet被拆解成features和classifier两个模型来实现。在训练时,可以为features和classifier分别指定不同的学习率。 对于{'params': model.classifier.parameters(), 'lr': 1e- 阅读全文
posted @ 2019-05-18 17:19 listenviolet 阅读(1967) 评论(0) 推荐(0)
摘要:1. torch.nn与torch.nn.functional之间的区别和联系 https://blog.csdn.net/GZHermit/article/details/78730856 nn和nn.functional之间的差别如下,我们以conv2d的定义为例 torch.nn.Conv2d 阅读全文
posted @ 2019-05-04 19:22 listenviolet 阅读(2544) 评论(0) 推荐(1)