自定义博客皮肤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的博客

采坑&填坑

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

原创 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 85979 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 973

转载 pytorch 模型的保存和加载

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

2018-03-28 17:03:53 3005

原创 Pytorch model.train model.eval

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

2018-03-23 21:24:29 12214 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 3912

原创 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 1488

原创 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 1407

转载 Pytorch 中的detach 和detach_

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

2018-03-18 20:41:21 9675 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 5041

原创 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 1502

转载 pytorch CrossEntropyLoss

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

2018-03-16 22:19:10 1879

原创 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 531

原创 epoch, iteration

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

2018-03-16 09:23:29 343

原创 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 1494 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 593

原创 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 2669

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关注的人

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