
深度学习
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 评论 -
ubuntu编译tensorflow 支持AVX,AVX2等指令集
1.下载安装bazel$ sudo apt-get update && sudo apt-get install bazelhttps://docs.bazel.build/versions/master/install-ubuntu.html2.克隆代码$ git clone https://github.com/tensorflow/tensorflo...原创 2020-01-07 18:15:49 · 2244 阅读 · 0 评论 -
L1正则和L2正则对网络参数的影响
一、正则化的来源 在深度网络的训练中,参数如果没有一个”正则化”的限制,很可能会导致过拟合(容易过大或过小),因此在制定损失函数时,往往加入对参数的约束,这就是正则化,通常的正则化有L1正则,L2正则或者两者的搭配权重使用。无论是L1还是L2正则,都有着把参数量变小的效果,但是L1正则由于函数图像的特殊性,导致了一种稀疏化的特性,便于选择特征。二、L1正则的稀疏化选择特...原创 2020-01-06 22:30:07 · 606 阅读 · 0 评论