自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

ZHOU的博客

采坑&填坑

  • 博客(36)
  • 资源 (1)
  • 收藏
  • 关注

原创 pyrouge 安装指南

git clone https://github.com/bheinzerling/pyrougecd pyrougepython setup.py installpyrouge_set_rouge_path your_rouge_path/ROUGE-1.5.5python -m pyrouge.test

2021-02-16 16:59:30 478

原创 python print(*values,sep='',end='',args) 函数

print(*values, sep=' ', end='\n', file=sys.stdout, flush=False)# values 表示多个要print 的值,可以是一个函数的返回# sep='\n' 表示返回值之间用\n 分开# file 参数可以指定打印输出文件...

2020-03-05 13:06:51 705 1

原创 torch.stack(list)

torch.stack(list,0)list 中的每个元素为tensor 中第0维度的每个元素import torcha = torch.Tensor([[1, 3, 2], [1, 3, 2]])b = torch.Tensor([[2, 1, 1], [2, 1, 1]])c = torch.Tensor([[3, 2, 3], [2, 1, 1]])my_list =...

2018-12-15 11:40:14 9067

原创 Python 3 collections.defaultdict()

创建各种数据类型的对象。 与传统方法不一样的地方在于,其key值不存在的时候不会报错,会根据特定类型返回不一样的值from collections import defaultdictd1 = dict()print(d1['a'])-->Traceback (most recent call last): File "C:\Users\ZHOU\Desktop\DS....

2018-11-13 20:17:01 582

转载 Python字符串格式化--format()方法

1.简单运用字符串类型格式化采用format()方法,基本使用格式是:     <模板字符串>.format(<逗号分隔的参数>)调用format()方法后会返回一个新的字符串,参数从0 开始编号。print("{}:计算机{}的CPU 占用率为{}%。".format("2016-12-31","PYTHON",10))output: '2016-12...

2018-10-31 15:57:03 1859

转载 numpy中flatten()函数用法

flatten是numpy.ndarray.flatten的一个函数,其官方文档是这样描述的:ndarray.flatten(order='C')Return a copy of the array collapsed into one dimension.Parameters:  order : {‘C’, ‘F’, ‘A’, ‘K’}, optional ...

2018-10-31 15:49:39 29473

原创 python 计算运行时间

方法1import datetimestarttime = datetime.datetime.now()#long runningendtime = datetime.datetime.now()print (endtime - starttime).seconds方法 2start = time.time()run_fun()end = time.time()print(end-...

2018-06-20 18:27:46 1782

转载 BM25 算法-词与文本相关性计算

BM25算法,通常用来作搜索相关性平分。一句话概况其主要思想:对Query进行语素解析,生成语素qi;然后,对于每个搜索结果d,计算每个语素qi与d的相关性得分,最后,将qi相对于d的相关性得分进行加权求和,从而得到Query与d的相关性得分。BM25算法的一般性公式如下: 其中,Q表示Query,qi表示Q解析之后的一个语素(对中文而言,我们可以把对Query的分词作为语素分析,每个词看成语素q...

2018-06-14 10:08:21 1919

原创 Matplotlib 远程画图报错

本地用matplotlib绘图可以,但是在ssh远程绘图的时候会报错matplotlib的默认backend是TkAgg,而FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg这几个backend都要求有GUI图形界面的,所以在ssh操作的时候会报错查看import matplotlib.pyplot as pltBackend TkAgg is...

2018-05-23 12:19:19 3284 2

原创 Python 作图之Matplotlib(二)

Legend import matplotlib.pyplot as pltimport numpy as npx = np.linspace(-3, 3, 50)y1 = 2*x + 1y2 = x**2plt.figure()#set x limitsplt.xlim((-1, 2))plt.ylim((-2, 3))# set new sticksnew_stick...

2018-05-23 11:08:12 481

原创 Python 作图之Matplotlib(一)

基本用法import matplotlib.pyplot as pltimport numpy as npx = np.linspace(-3, 3, 50)x = np.linspace(-3, 3, 50)y1 = 2*x + 1y2 = x**2plt.figure()plt.plot(x, y)plt.show()设置样式使用plt.figure定义一个图像窗口:编号为3;大...

2018-05-23 10:59:11 721

原创 Linux 后台运行程序

nohup ./run.sh >& xxx.log &后台运行程序,并保留错误和输出日志tail -f xxx.log  实时查看日志命令less   xxx.log  查看全部输出命令

2018-05-18 19:11:57 225

转载 python 存储数据的方式

转自https://blog.csdn.net/weixin_39198406/article/details/78231430json文件json是一种轻量级的数据交换格式。采用完全独立于编程语言的文本格式来存储和表示数据。层次结构简洁而清晰,易于人阅读和编写,同时也易于机器解析和生成,并有效地提升网络传输效率。最主要的是,通过json这个包可以很方便的解决无论是py2还是py3中的编码问题,j...

2018-05-17 21:43:46 2898

转载 Datasets-20news

源自如http://qwone.com/~jason/20Newsgroups/。20newsgroups数据集是用于文本分类、文本挖据和信息检索研究的国际标准数据集之一。数据集收集了大约20,000左右的新闻组文档,均匀分为20个不同主题的新闻组集合。一些新闻组的主题特别相似(e.g. comp.sys.ibm.pc.hardware/ comp.sys.mac.hardware),还有一些却完...

2018-05-14 11:47:42 306

原创 vim 显示行号

编辑模式下输入:set number/:set nu永久设置vim ~/.vimrc 添加set number /set nusource ~/.vimrc

2018-05-05 17:05:04 214

原创 Pytorch BUG 持续填坑

BUG1在做多分类的时候,计算LOSS 报错:cuda runtime error (59) : device-side assert triggered at /opt/conda/conda-bld/pytorch_1513368888240/work/torch/lib/THC/generated/../THCReduceAll.cuh:33这是因为 在计算loss的时候 data labe...

2018-04-19 15:39:07 5662 9

原创 Pytorch 保存和加载模型 part2

搭建网络:torch.manual_seed(1) # reproducible# 假数据x = torch.unsqueeze(torch.linspace(-1, 1, 100), dim=1) # x data (tensor), shape=(100, 1)y = x.pow(2) + 0.2*torch.rand(x.size()) # noisy y data (te...

2018-04-04 10:21:57 634

原创 Pytorch Variable

Variable 没有 reshape 和resize ? 只能先转化成tensor/ndarry 再操作?dir(FOO) 看对象所有属性

2018-04-02 23:21:33 495

原创 torch.reshape /torch.Tensor.reshape

y = x.reshape([batchsize, -1, sentsize, wordsize])把 x 改变形状为(batch,-1, sentsize, wordsize)-1 维度会自动根据其他维度计算x = np.transpose(x,axes=(1,0,2,3)) 把x 转置 axes: 要进行转置 的轴兑换序号arr1 = np.arange(12).reshape(2,2,3)...

2018-04-02 15:36:21 30404 2

原创 Linux Top Free

显示参数:PID(Process ID):进程标示号。USER:进程所有者的用户名。PR:进程的优先级别。NI:进程的优先级别数值。VIRT:进程占用的虚拟内存值。RES:进程占用的物理内存值。SHR:进程使用的共享内存值。S:进程的状态,其中S表示休眠,R表示正在运行,Z表示僵死状态,N表示该进程优先值是负数。%CPU:该进程占用的CPU使用率。%MEM:该进程占用的物理内存和总内存的百分比。T...

2018-04-01 20:43:17 326

原创 torch.max

torch.max(input) → Tensor返回输入tensor中所有元素的最大值a = torch.randn(1, 3)>>0.4729 -0.2266 -0.2085torch.max(a)>>0.4729  torch.max(input, dim, keepdim=False, out=None) -> (Tensor, ...

2018-03-31 10:55:46 85719 7

转载 学会区分 RNN 的 output 和 state

本文转至https://zhuanlan.zhihu.com/p/28919765调用 outputs, last_state = tf.nn.static_rnn(cell, inputs) 之后,last_state 和 outputs[-1] 相等吗?如果不想等,为什么会不等呢?其实这也是学习 RNN 的一大难点。我个人认为,学习 RNN 最难的地方就是弄明白它的输入和输出是什么。一个简单的...

2018-03-28 21:48:34 871

转载 pytorch 模型的保存和加载

本文转至:https://byjiang.com/2017/06/05/How_To_Save_And_Restore_Model/在模型完成训练后,我们需要将训练好的模型保存为一个文件供测试使用,或者因为一些原因我们需要继续之前的状态训练之前保存的模型,那么如何在PyTorch中保存和恢复模型呢?方法一(推荐):第一种方法也是官方推荐的方法,只保存和恢复模型中的参数。保存torch.save(t...

2018-03-28 17:03:53 2955

原创 Pytorch model.train model.eval

model.train()    model.eval()一般在模型训练和评价的时候会加上这两句,主要是针对model 在训练时和评价时不同的 Batch Normalization  和  Dropout 方法模式

2018-03-23 21:24:29 12194 2

原创 vstack

numpy.vstack(tup)将数组堆叠成一列。方法 等同于 np.concatenate(tup, axis=0)参数 :tup -- sequence of ndarrays Tuple containing arrays to be stacked. The arrays must have the same shape along all but the first axis.返回 :...

2018-03-20 11:19:04 3860

原创 Gensim Word2vec 使用教程

存储加载模型model = Word2Vec.load_word2vec_format('/./data/GoogleNews-vectors-negative300.txt', binary=False)# using gzipped/bz2 input works too, no need to unzip:model= Word2Vec.load_word2vec_format('./...

2018-03-20 11:06:26 1448

原创 Python zip() 与zip (*)

zip() 和zip(*)参数是迭代器iteration函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。3.0 返回的是zip对象 如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同。利用 * 号操作符,可以将元组解压为列a = [1,2,3]b = [4,5,6]c = [4,5,6,7,8]zipped = zip(a,b)...

2018-03-20 09:56:52 1381

转载 Pytorch 中的detach 和detach_

本文转自 http://blog.csdn.net/u012436149/article/details/76714349pytorch 的 Variable 对象中有两个方法,detach和 detach_ 本文主要介绍这两个方法的效果和 能用这两个方法干什么detach官方文档中,对这个方法是这么介绍的。返回一个新的 从当前图中分离的 Variable。返回的 Variable 永远不会需要梯...

2018-03-18 20:41:21 9593 2

转载 NN.Embedding

在pytorch里面实现word embedding是通过一个函数来实现的:nn.Embedding# -*- coding: utf-8 -*-import numpy as npimport torchimport torch.nn as nnimport torch.nn.functional as Ffrom torch.autograd import Variablewor...

2018-03-17 13:00:21 5002

原创 Pytorch NN初始化参数

torch.nn.init.xavier_uniform(tensor, gain=1)using a uniform distribution values fills the input Tensor or Variable The resulting tensor will have values sampled from U (-a ,a)生成值都均匀分布在(-a,a)之间的 tensor...

2018-03-17 10:57:50 1480

转载 pytorch CrossEntropyLoss

多分类用的交叉熵损失函数,用这个 loss 前面不需要加 Softmax 层。这里损害函数的计算,按理说应该也是原始交叉熵公式的形式,但是这里限制了 target 类型为 torch.LongTensr,而且不是多标签意味着标签是 one-hot 编码的形式,即只有一个位置是 1,其他位置都是 0,那么带入交叉熵公式中化简后就成了下面的简化形式。loss(x,label)=−wlabellogex...

2018-03-16 22:19:10 1826

原创 enumerate、yield

enumerate(iterable,start=0)Return an enumerate object. iterable must be a sequence返回一个枚举对象,第一个参数是迭代器,第二个参数指定开始index, 默认从0开始>>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']>>> li...

2018-03-16 15:57:15 494

原创 epoch, iteration

NN训练中一次迭iteration选取一个batch进行update。一个epoch是指把所有训练数据完整的过一遍因此一个epoch就是iteration次数*batch的数目 ==训练数据的个数。(batch 是把所有数据分批成batch 个)...

2018-03-16 09:23:29 311

原创 range

range(start, stop [,step])start: 计数从 start 开始。默认是从 0 开始。例如range(5)等价于range(0, 5);stop: 计数到 stop 结束,但不包括 stop。例如:range(0, 5) 是[0, 1, 2, 3, 4]没有5step:步长,默认为1。例如:range(0, 5) 等价于 range(0, 5, 1)range(10)# ...

2018-03-15 22:23:08 1468 1

原创 BATCH BATCHSIZE narrow tensor.view()

BATCHdivide the dataset into BATCHSIZE parts.批处理训练数据,把训练数据分成BATCHSIZE 份BATCHSIZE把所有data分成 batchsize份,每个BATCH 有data.size(0)//BATCHSIZE 条数据 !!!(注意不是每份数据batch条)tensor.narrow(dim, start, length) # Returns...

2018-03-15 21:37:12 554

原创 map、lambda、list 表达式的理解

map对列表/迭代器中每个元素执行function 函数map(function, iterable, ...)Python 3 返回迭代器, 转化成列表需要用list(map(fuc,list))lambdalambda 匿名函数 l 为 函数flatten 的输入,返回的是:后面的.list 多个 for 循环的使用import os#导入模块g=os.walk("C:\\SWTOOLS")...

2018-03-15 20:59:34 2630

acl2016 best paper

ACL 2016 best paper 之一Combining deep neural networks with structured logic rules is desirable to harness flexibility and reduce uninterpretability of the neural models. We propose a general framework capable of enhancing various types of neural networks (e.g., CNNs and RNNs) with declarative first-order logic rules. Specifically, we develop an iterative distillation method that transfers the structured information of logic rules into the weights of neural networks. We deploy the framework on a CNN for sentiment analysis, and an RNN for named entity recognition. With a few highly intuitive rules, we obtain substantial improvements and achieve state-of-the-art or comparable results to previous best-performing systems.

2017-09-16

空空如也

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

TA关注的人

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