
pytorch
king的江鸟
like wind,be like wind
展开
-
pytorch BILSTM-CRF bacth版本实现
import torchimport torch.nn as nnimport torch.optim as optimimport torch.utils.data as Datatorch.manual_seed(1)IF_CUDA = Falseif torch.cuda.is_available(): try: IF_CUDA = True ...原创 2020-03-23 14:16:14 · 2763 阅读 · 12 评论 -
pytorch bilstm-crf的crf score代码实现详解
本文适合已经基本了解crf原理的读者,深入探究代码层面的实现原理1. _forward_alg代码 def _forward_alg(self, feats): # Do the forward algorithm to compute the partition function init_alphas = torch.full((1, self....原创 2020-03-04 16:49:54 · 1218 阅读 · 0 评论 -
pytorch使用batch训练lstm网络实现
pytorch使用batch的时候一定要注意训练和预测的区别,通常需要编写predict代替forward,另外loss_function也需要针对batch进行重构。接下来我会展示出两段代码,展示使用batch的细节。1. 未使用batch的lstm#导入相应的包import torchimport torch.nn as nnimport torch.nn.functional...原创 2020-02-23 16:32:28 · 5391 阅读 · 1 评论