pytorch
sinat_15355869
这个作者很懒,什么都没留下…
展开
-
BILSTM-CNN-CRF 学习
论文:End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF学习笔记:见云盘(挖个坑)代码:from __future__ import print_functionfrom collections import OrderedDictimport torchimport torch.nn as nnfro...原创 2019-12-01 21:57:16 · 2416 阅读 · 2 评论 -
Char-RNN pytorch 官方
链接:代码:from __future__ import unicode_literals, print_function, divisionfrom io import openimport globimport osimport unicodedataimport string"""Python glob()函数的作用和用法https://blog.csdn.net...原创 2019-10-15 18:53:20 · 419 阅读 · 0 评论 -
pytorch lstm - 来自官网
代码:import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimtorch.manual_seed(1)# 基础知识复习 nn.LSTM 的输入与输出"""rnn = nn.LSTM(10, 20, 2) # input_size, hidden_s...原创 2019-10-12 18:52:17 · 357 阅读 · 0 评论 -
skip-gram
import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.utils.data as tudfrom collections import Counterimport numpy as npimport randomUSE_CUDA = torch.cuda.is_availabl...原创 2019-07-09 18:19:18 · 401 阅读 · 0 评论 -
fizz_buzz update
【转】:https://mathpretty.com/10526.html 修改了模型的结构:效果显著# @TIME : 2019/7/9 下午8:42# @File : FizzBuzz_new.pyimport numpy as npimport torchimport torch.nn as nnimport torch.utils.data as tudfro...转载 2019-07-10 00:05:00 · 423 阅读 · 0 评论 -
rnn_language_model
import numpy as npdef random_init(num_rows, num_cols): return np.random.rand(num_rows, num_cols)*0.01def zero_init(num_rows, num_cols): return np.zeros((num_rows, num_cols))class DataRe...原创 2019-07-18 14:40:30 · 169 阅读 · 0 评论 -
rnn numpy
【转】https://zybuluo.com/hanbingtao/note/541458【转】karpathy/min-char-rnn.py# @TIME : 2019/7/21 下午02:07# @File : RNN_numpy.pyimport numpy as npfrom functools import reduceclass ReluActivato...原创 2019-07-22 02:04:39 · 166 阅读 · 0 评论 -
torchtext - Field 源码
pytorch-Field 源码:text/torchtext/data/field.py 【转】如何利用torchtext读取json文件并生成batch 作者:Geek Fly --> 这篇文章挺好的# coding: utf8from collections import Counter, OrderedDictfrom itertools import ch...原创 2019-07-25 23:00:51 · 1196 阅读 · 0 评论 -
avg_pool2d - pytorch
链接:https://pytorch.org/docs/stable/nn.html?highlight=avg_pool2d#torch.nn.functional.avg_pool2d链接:https://pytorch.org/docs/stable/nn.html?highlight=avg_pool1d#torch.nn.AvgPool2d以下用来回忆使用:截图:、...原创 2019-07-26 16:06:30 · 231 阅读 · 0 评论 -
torchtext -> 基本
# @TIME : 2019/7/31 上午00:35# @File : A - Using TorchText with Your Own Datasets.py""" define the Fields loaded the dataset created the splits TEXT = data.Field() LABEL = data.LabelField()...原创 2019-08-01 00:49:21 · 418 阅读 · 2 评论 -
torch squeeze & unsqueeze
官方解释:用法截图:unsqueeze用法截图:squeeze官方链接:https://pytorch.org/docs/stable/torch.html#torch.squeezehttps://pytorch.org/docs/stable/torch.html#torch.unsqueeze...原创 2019-07-28 01:38:31 · 98 阅读 · 0 评论 -
pytorch IMDB - avgmodel
github:https://github.com/yjfiejd/2019xuexi/tree/master/Pytorch_new一、问题:情感分析问题:数据大概长啥样:train_data: {'text': ['ab', 'cd', 'dd', xxx], 'label': 'pos'}二、思路:"""代码逻辑:1)用torchtext中自带的datasets...原创 2019-07-28 16:37:38 · 1561 阅读 · 3 评论 -
pytorch RNN - Language Models
pytorch 文档:https://pytorch.org/docs/stable/nn.html?highlight=lstm#torch.nn.LSTMtorchtext 文档:https://torchtext.readthedocs.io/en/latest/#参考论文: Neural Nets and Neural Language Models.Dan Jura...原创 2019-07-13 11:44:48 · 429 阅读 · 0 评论 -
crf_lianxi
crf:# @TIME : 2019/3/17 下午10:52# @File : chainer_implementation.py# 参考:https://github.com/createmomo/CRF-Layer-on-the-Top-of-BiLSTMimport numpy as npimport chainerimport chainer.links as ...转载 2019-03-18 08:32:37 · 148 阅读 · 0 评论 -
crf-lijie
import torchimport torch.autograd as autogradimport torch.nn as nnimport torch.optim as optimtorch.manual_seed(1)def argmax(vec): # return the argmax as a python int _, idx = torch.max...转载 2019-03-20 10:02:30 · 115 阅读 · 0 评论 -
Pytorch_学习_cnn
直接代码:import torchimport torch.nn as nnimport torch.utils.data as Dataimport torchvisionimport matplotlib.pyplot as plt# Hyper parameterstorch.manual_seed(1)EPOCH = 1 #训练一批次BATCH_SICE = 5...原创 2019-01-19 15:12:42 · 238 阅读 · 0 评论 -
pytorch_practice_main
举例# -*- coding:utf-8 -*-import pickleimport sysimport yamlimport torchimport torch.optim as optimfrom data_manager import DataManagerfrom model import BiLSTMCRFfrom utils import f1_score...原创 2019-02-22 08:47:20 · 247 阅读 · 0 评论 -
pytorch_practice_data manager
import copyimport pickle as cPickleimport torchclass DataManager(): def __init__(self, max_length=100, batch_size=20, data_type='train', tags=[]): self.index = 0 self.in...原创 2019-02-22 08:58:36 · 205 阅读 · 0 评论 -
pytorch_practice_model
import copyimport numpy as npimport torchimport torch.nn.functional as Ffrom torch import nnSTART_TAG = "START"STOP_TAG = "STOP"def log_sum_exp(vec): max_score = torch.max(vec...原创 2019-02-22 08:59:35 · 169 阅读 · 0 评论 -
build vocab
"""Build vocabularies of words and tags from datasets"""import argparsefrom collections import Counterimport jsonimport osparser = argparse.ArgumentParser()parser.add_argument('--min_count_w...原创 2019-02-20 08:50:10 · 2262 阅读 · 0 评论 -
train model
Train your experiment. Simply runpython train.py --data_dir data/small --model_dir experiments/base_modelIt will instantiate a model and train it on the training set following the hyperparamet...原创 2019-02-21 08:40:56 · 751 阅读 · 2 评论 -
word-embedding
代码import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimtorch.manual_seed(1)CONTEXT_SIZE = 2EMBEDDING_DIM = 30EPOCH = 100VERVOSE = 5# 0) 文本分开corpus_...原创 2019-03-02 16:30:23 · 323 阅读 · 0 评论 -
CBOW 更新
代码:import torchimport torch.nn as nnimport numpy as npdef make_context_vector(context, word_to_ix): idxs = [word_to_ix[w] for w in context] return torch.tensor(idxs, dtype=torch.long)...转载 2019-03-02 16:40:11 · 419 阅读 · 0 评论 -
lianxi
代码import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimtorch.manual_seed(1)# 1) 准备数据def prepare_sentence(seq, to_ix): idx = [to_ix[w] for w in seq...原创 2019-03-08 21:59:59 · 202 阅读 · 0 评论 -
fuxi cbow
# @TIME : 2019/3/4 上午00:38# @File : CBOW_2.pyimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimclass CBOW(nn.Module): def __init__(self, vocab_si...原创 2019-03-04 08:30:26 · 99 阅读 · 0 评论 -
lstm parctice
代码:# @TIME : 2019/3/5 上午8:07# @File : LSTM_3_5.pyimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimtorch.manual_seed(1)# # 0) 定义 input 3, output ...原创 2019-03-07 09:03:17 · 144 阅读 · 0 评论 -
pytorch_parctice_00
基本操作:# standard libraryimport os# third-party libraryimport torchimport torch.nn as nnimport torch.utils.data as Dataimport torchvisionimport matplotlib.pyplot as plt# torch.manual_seed(1...转载 2019-01-19 15:05:21 · 207 阅读 · 0 评论