摘要: 1. **args, **kwargs的区别 2. np.sum 3. use numpy to solve grad PyTorch自动计算梯度 x is a variable, requires_grad=True. x.data is a tensor. x.grad is a variabl 阅读全文
posted @ 2017-07-21 16:17 Joyce_song94 阅读(1490) 评论(0) 推荐(0) 编辑
摘要: 1 import torch 2 from torch import nn, optim 3 from torch.autograd import Variable 4 import torch.nn.functional as F 5 6 CONTEXT_SIZE = 2 # 2 words to the left, 2 to the right 7 raw_text = "... 阅读全文
posted @ 2017-07-13 10:21 Joyce_song94 阅读(2194) 评论(0) 推荐(0) 编辑
摘要: 1 import torch 2 import torch.nn as nn 3 from torch.autograd import Variable 4 import torch.nn.functional as F 5 import torch.optim as optim 6 7 CONTEXT_SIZE = 2 # the same as wind... 阅读全文
posted @ 2017-07-13 09:53 Joyce_song94 阅读(1929) 评论(0) 推荐(0) 编辑
摘要: 1 import torch 2 import torch.nn as nn 3 from torch.autograd import Variable 4 5 word2id = {'hello': 0, 'world': 1} 6 # you have 2 words, and then need 5 dim each word 7 embeds = nn.Embedding... 阅读全文
posted @ 2017-07-13 08:43 Joyce_song94 阅读(3794) 评论(0) 推荐(0) 编辑
摘要: 一、情感分类方面 为了提高CNN情感分类的准确率,对CNN模型的输入层进行改进,加入word2vec。 各个方案基于这样的前提: a. 经过上个星期调试,当KERNEL_NUM=200, KERNEL_SIZES=[3, 4, 5, 6, 7] 时准确率最高,所以下面所有改进都是基于此结论的基础上的 阅读全文
posted @ 2017-07-11 22:43 Joyce_song94 阅读(142) 评论(0) 推荐(0) 编辑
摘要: heapq内置模块位于./Anaconda3/Lib/heapq.py,提供基于堆的优先排序算法 堆的逻辑结构就是完全二叉树,并且二叉树中父节点的值小于等于该节点的所有子节点的值。这种实现可以使用 heap[k] <= heap[2k+1] 并且 heap[k] <= heap[2k+2] (其中 阅读全文
posted @ 2017-07-11 10:48 Joyce_song94 阅读(16649) 评论(0) 推荐(0) 编辑
摘要: 1. np.size和np.prod 1 import numpy as np 2 x = np.zeros((3, 5, 2), dtype=np.complex128) 3 # ndarray.size is the number of elements in the array 4 # equ 阅读全文
posted @ 2017-07-09 17:15 Joyce_song94 阅读(2289) 评论(0) 推荐(0) 编辑
摘要: 一、CNN情感分类中的面向对象部分 sparse.py 表示需要父类初始化,即要运行父类的_init_(),如果没有这个,则要自定义初始化 结果如下: conv.py _pair()跳转到utils.py 这是一个函数式编程的写法,涉及函数嵌套。举例如下: 1. repeat(x, n)跳转之后只有 阅读全文
posted @ 2017-07-05 02:22 Joyce_song94 阅读(4267) 评论(0) 推荐(0) 编辑
摘要: 刘知远老师博士论文-基于文档主题结构的关键词抽取方法研究 一、研究背景和论文工作介绍 关键词抽取分为两步:选取候选关键词和从候选集合中推荐关键词。 1.1. 选取候选关键词 关键词:单个词或者多个单词组成的短语。 抽取难点:如何正确判定候选关键词的边界。(在英文关键词抽取中,一般选N元词串,计算N元 阅读全文
posted @ 2017-07-05 01:06 Joyce_song94 阅读(583) 评论(0) 推荐(0) 编辑
摘要: re 模块使 Python 语言拥有全部的正则表达式功能。 compile 函数根据一个模式字符串和可选的标志参数生成一个正则表达式对象。该对象拥有一系列方法用于正则表达式匹配和替换。 使用group(num) 或 groups() 匹配对象函数来获取匹配表达式。 groups():返回一个包含所有 阅读全文
posted @ 2017-07-03 15:18 Joyce_song94 阅读(598) 评论(0) 推荐(0) 编辑