自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 怎样用Python写一个Linux命令行

一般来说,我们的命令行需要执行两个及以上的函数,我们先定义两个简单的函数。def add(x,y): ''' x plus y ''' return(x+y)def mul(x,y): ''' x times y ''' return(x*y)导入包import argparseimport sys主函数,执行上面两个函数的功能。def main(args): print(add(args.a,args.b))

2021-02-19 09:59:11 599 1

原创 LIME与模型可解释性研究 (先写一点,有空继续更)

LIME的基本思想是,对于测试集中的样本进行分析,看模型(不论是机器学习还是深度学习)用了哪些特征来输出某个结果。分析样本时,对样本进行一定程度的扰动,使得这些经过扰动获得的点位于原样本点附近(这里的距离可以用余弦相似度或者L2距离来衡量),观察这些扰动的点的输出是什么样的。同时,LIME要用到某个模型,这里叫做explainer,用到分类器种学到的特征,然后expaliner是个简单的模型,例如线性回归或者决策树,要满足explainer输出的结果尽可能接近分类器的输出结果。其实我们可以看出,分类器

2021-02-16 17:12:54 451

原创 什么是micro-F1和macro-F1 (顺便谈谈精准率与召回率)

什么是micro-F1和macro-F1 (顺便谈谈精准率与召回率)TP: true positive, 预测和实际相同;(预测和真实都是A)FP: false positive, 预测为正,实际为负;(预测是A,真实不是A)FN: false negative, 预测为负,实际为正;(真实是A,但没有预测成A)例如:预测真实AAAABACABBBBCBBCCC可知对于A、B、C类,有:TPF

2021-02-04 14:29:59 1058

原创 英语学习方法:我是怎么从高考英语115考到托福97的

文章目录一、我的英语学习经历二、英语能力是什么三、学习英语的基本方法单词怎么背单词阅读听力如何提高四、Tips一、我的英语学习经历我是2015年参加高考,高考英语115分,是一个非常平均的水平,当年大多数优秀的人都能考到125甚至130分。所以这篇文章对像我这样一开始处于平均水平的人应该是非常有用的。大一考四级500分,大一下学期裸考六级350分。大一暑假在外面机构培训托福一个月;大二背单词书一整年(后面我会详细说是怎么背的),偶尔做点托福的阅读和听力;大二暑假一对一培训托福一个月,培训后即首考托福86

2021-01-15 09:45:33 1770 7

原创 Transformer中数据维度的变化和mask

会用到的一些函数nn.Embedding()和padding_idxa = torch.LongTensor([0,1,2,3,4])emb = nn.Embedding(10,5,padding_idx=0)emb(a)## output:# tensor([[ 0.0000, 0.0000, 0.0000, 0.0000, 0.0000],# [ 1.2378, 0.2666, 0.3143, -0.4785, -0.0261],# [ 0.

2021-01-13 16:02:12 3578 3

原创 NLP 怎样把训练数据每一个句子用向量表示

前言首先我们需要一个词库(vocabulary),包含常见词汇以及<unk>, <BOS>, <EOS>, <PAD> 等等。同时有词库相对应的两个数据:word->index和index->word。拿到数据文本txt之后,按行读取文件,每一行一个句子,我们要做的就是把每一个句子转换成向量表示,句子中的单词用one-hot embedding表示,也就是word->index中的index,同时加上特殊字符<unk>, &lt

2020-12-03 10:18:23 882

原创 NLP数据预处理

前言文本的常见格式是txt,我们需要把txt文件中的每一句话中的每一个单词提取出来建立词库。通常,建立三个字典:word->index, index->word, word->frequency.此外,由于将来处理文本时会遇到不在词库中的单词,所以添加<unk>, <pad>, <EOS>, <BOS>等特殊词。以下内容以建立一个处理文本的类为例。from collections import defaultdictUNK_T

2020-12-03 05:22:37 546

原创 【文献解读】Generating Sentences from a Continuous Space,VAE产生连续空间变量

AbstractThe standard RNN: doesn’t work for global sentence representation;The work of this paper: RNN-based variational autoencoder generative model;The model: incorporates distributed latent representations of entire sentences; good at modeling

2020-11-20 04:00:33 1856

原创 pytorch实现线性回归

导入包import torchfrom torch import nnimport numpy as nptorch.manual_seed(1)print(torch.__version__)torch.set_default_tensor_type('torch.FloatTensor')import torch.utils.data as Datafrom torch.nn import init线性回归num_inputs = 2num_examples = 1000tru

2020-11-15 21:43:21 195

原创 Approximation Algorithm1(近似算法(一))(Introduction to Algorithms, 算法导论,CLRS)学习笔记

Approximation Algorithm1. Approximation ratioCost: the size of the solution, for example, in vertex cover, it’s the size of the cover; in TSP, it’s the total distance.Since the approximation algorithm, the cost we have is always greater than the optima

2020-10-16 23:21:18 1660 1

原创 Exact exponential algorithms and parameterized complexity指数算法和参数复杂性(Introduction to Algorithms, 算法导论

Exact exponential algorithms and parameterized complexityWe usually want algorithms that:in polynomial time;for all instances;find an exact solution;We can settle for 2 out of 3:relax 1: exponential algorithmrelax 2: parameterizedrelax 3: approx

2020-10-16 16:19:06 389

原创 NP completeness(NP完整性)(Introduction to Algorithms, 算法导论,CLRS)学习笔记

NP completenessHere we use binary string in our problems;Call an instance of a problem language, and x∈{0,1}∗x\in\{0,1\}^*x∈{0,1}∗ means the input of the language x is encoded in binary; A(X)=1/0A(X)=1/0A(X)=1/0 means there is a verification algorithm A

2020-10-14 21:45:51 505

原创 van Emde Boas Trees(vEB树)(Introduction to Algorithms, 算法导论,CLRS)学习笔记

van Emde Boas Trees1. Predecessor search/ordered setspredecessor: return the nearest left neighborsuccessor: return the nearest right neighbor2.Naive: O(∣U∣)O(|U|)O(∣U∣) spacepredecessor/successor: if x∈Sx\in Sx∈S then it’s O(1)O(1)O(1);insert:

2020-10-12 21:44:57 613

原创 Hashing哈希函数(Introduction to Algorithms, 算法导论,CLRS)学习笔记

HashingHashing fundamentalsApplication: Unordered setsHash table with chainingPractical universal hash functionsApplication: Coordinated sampling1. Hashing fundamentalsNotation:For n∈Nn\in Nn∈N:[n]={0,...,n−1}[n]=\{0,...,n-1\}[n]={0,...,n−1}

2020-10-11 23:51:32 653

原创 Randomized Algorithms随机算法(Introduction to Algorithms, 算法导论,CLRS)学习笔记

Randomized AlgorithmsLas Vegas Algorithm for quick sortMonte Carlo Algorithm for find min cutThe quick sort:Best case: each time the chose pivot is in the middle; O(nlog⁡n)O(n\log n)O(nlogn);Worst case: in a sorted list, each time the chosen pi

2020-10-11 15:47:03 787

原创 NLTK处理文本(一)

NLTK处理文本(一)导入包import nltknltk.download()from nltk.book import *查看文本text7text7len(set(text7))## 统计词频dist = FreqDist(text7)## 查看某个词出现的次数dist["four"]##筛选长度大于5且词频大于100的词freqwords = [w for w in vocab1 if len(w) > 5 and dist[w]>100]归一化与合法化(

2020-10-10 21:59:39 547

原创 Linear Programming线性规划(Introduction to Algorithms, 算法导论,CLRS)学习笔记

Linear Programming1. Fundamentalsobjective function and constraints:min/max3x1+24x2+13x3+9x4...s.t    linear  constraintsmin/max\quad 3x_1+24x_2+13x_3+9x_4...\\s.t\quad\;\; linear\; constraints min/max3x1​+24x2​+13x3​+9x4​...s.tlinearconstraintsopt

2020-10-10 02:23:43 650

原创 Max flow最大流(Introduction to Algorithms, 算法导论,CLRS)学习笔记

Max Flow1. FoundationsWhat we do in Max flow: Given a flow network G with source sss and sink ttt, to find a flow of maximum valueWhat is a valid flow: must satisfy both: 1. flow constraint; 2. flow conservation2. Define a max-flow problemG=(V,

2020-10-09 17:33:22 891

原创 Text Mining in Python 学习笔记【一】

常用的字符串处理函数s.split()s.strip()s.rstrip()s.istitle()s.startwith()s.endwith()set(a_list)s.lower()s.upper()s.Capitalize()

2020-10-07 21:15:17 428

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除