
pytorch
sinat_15355869
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
BILSTM-CNN-CRF 学习
论文:End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF 学习笔记:见云盘(挖个坑) 代码: from __future__ import print_function from collections import OrderedDict import torch import torch.nn as nn fro...原创 2019-12-01 21:57:16 · 2576 阅读 · 2 评论 -
Char-RNN pytorch 官方
链接: 代码: from __future__ import unicode_literals, print_function, division from io import open import glob import os import unicodedata import string """ Python glob()函数的作用和用法 https://blog.youkuaiyun.com...原创 2019-10-15 18:53:20 · 499 阅读 · 0 评论 -
pytorch lstm - 来自官网
代码: import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim torch.manual_seed(1) # 基础知识复习 nn.LSTM 的输入与输出 """ rnn = nn.LSTM(10, 20, 2) # input_size, hidden_s...原创 2019-10-12 18:52:17 · 420 阅读 · 0 评论 -
skip-gram
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data as tud from collections import Counter import numpy as np import random USE_CUDA = torch.cuda.is_availabl...原创 2019-07-09 18:19:18 · 471 阅读 · 0 评论 -
fizz_buzz update
【转】:https://mathpretty.com/10526.html 修改了模型的结构:效果显著 # @TIME : 2019/7/9 下午8:42 # @File : FizzBuzz_new.py import numpy as np import torch import torch.nn as nn import torch.utils.data as tud fro...转载 2019-07-10 00:05:00 · 481 阅读 · 0 评论 -
rnn_language_model
import numpy as np def random_init(num_rows, num_cols): return np.random.rand(num_rows, num_cols)*0.01 def zero_init(num_rows, num_cols): return np.zeros((num_rows, num_cols)) class DataRe...原创 2019-07-18 14:40:30 · 223 阅读 · 0 评论 -
rnn numpy
【转】https://zybuluo.com/hanbingtao/note/541458 【转】karpathy/min-char-rnn.py # @TIME : 2019/7/21 下午02:07 # @File : RNN_numpy.py import numpy as np from functools import reduce class ReluActivato...原创 2019-07-22 02:04:39 · 228 阅读 · 0 评论 -
torchtext - Field 源码
pytorch-Field 源码:text/torchtext/data/field.py 【转】如何利用torchtext读取json文件并生成batch 作者:Geek Fly --> 这篇文章挺好的 # coding: utf8 from collections import Counter, OrderedDict from itertools import ch...原创 2019-07-25 23:00:51 · 1297 阅读 · 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 · 289 阅读 · 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 · 496 阅读 · 2 评论 -
torch squeeze & unsqueeze
官方解释: 用法截图:unsqueeze 用法截图:squeeze 官方链接: https://pytorch.org/docs/stable/torch.html#torch.squeeze https://pytorch.org/docs/stable/torch.html#torch.unsqueeze ...原创 2019-07-28 01:38:31 · 143 阅读 · 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 · 1688 阅读 · 3 评论 -
pytorch RNN - Language Models
pytorch 文档:https://pytorch.org/docs/stable/nn.html?highlight=lstm#torch.nn.LSTM torchtext 文档:https://torchtext.readthedocs.io/en/latest/# 参考论文: Neural Nets and Neural Language Models.Dan Jura...原创 2019-07-13 11:44:48 · 483 阅读 · 0 评论 -
crf_lianxi
crf: # @TIME : 2019/3/17 下午10:52 # @File : chainer_implementation.py # 参考:https://github.com/createmomo/CRF-Layer-on-the-Top-of-BiLSTM import numpy as np import chainer import chainer.links as ...转载 2019-03-18 08:32:37 · 200 阅读 · 0 评论 -
crf-lijie
import torch import torch.autograd as autograd import torch.nn as nn import torch.optim as optim torch.manual_seed(1) def argmax(vec): # return the argmax as a python int _, idx = torch.max...转载 2019-03-20 10:02:30 · 155 阅读 · 0 评论 -
Pytorch_学习_cnn
直接代码: import torch import torch.nn as nn import torch.utils.data as Data import torchvision import matplotlib.pyplot as plt # Hyper parameters torch.manual_seed(1) EPOCH = 1 #训练一批次 BATCH_SICE = 5...原创 2019-01-19 15:12:42 · 284 阅读 · 0 评论 -
pytorch_practice_main
举例 # -*- coding:utf-8 -*- import pickle import sys import yaml import torch import torch.optim as optim from data_manager import DataManager from model import BiLSTMCRF from utils import f1_score...原创 2019-02-22 08:47:20 · 306 阅读 · 0 评论 -
pytorch_practice_data manager
import copy import pickle as cPickle import torch class 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 · 268 阅读 · 0 评论 -
pytorch_practice_model
import copy import numpy as np import torch import torch.nn.functional as F from torch import nn START_TAG = "START" STOP_TAG = "STOP" def log_sum_exp(vec): max_score = torch.max(vec...原创 2019-02-22 08:59:35 · 200 阅读 · 0 评论 -
build vocab
"""Build vocabularies of words and tags from datasets""" import argparse from collections import Counter import json import os parser = argparse.ArgumentParser() parser.add_argument('--min_count_w...原创 2019-02-20 08:50:10 · 2366 阅读 · 0 评论 -
train model
Train your experiment. Simply run python train.py --data_dir data/small --model_dir experiments/base_model It will instantiate a model and train it on the training set following the hyperparamet...原创 2019-02-21 08:40:56 · 865 阅读 · 2 评论 -
word-embedding
代码 import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim torch.manual_seed(1) CONTEXT_SIZE = 2 EMBEDDING_DIM = 30 EPOCH = 100 VERVOSE = 5 # 0) 文本分开 corpus_...原创 2019-03-02 16:30:23 · 397 阅读 · 0 评论 -
CBOW 更新
代码: import torch import torch.nn as nn import numpy as np def 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 · 486 阅读 · 0 评论 -
lianxi
代码 import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim torch.manual_seed(1) # 1) 准备数据 def prepare_sentence(seq, to_ix): idx = [to_ix[w] for w in seq...原创 2019-03-08 21:59:59 · 252 阅读 · 0 评论 -
fuxi cbow
# @TIME : 2019/3/4 上午00:38 # @File : CBOW_2.py import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim class CBOW(nn.Module): def __init__(self, vocab_si...原创 2019-03-04 08:30:26 · 131 阅读 · 0 评论 -
lstm parctice
代码: # @TIME : 2019/3/5 上午8:07 # @File : LSTM_3_5.py import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim torch.manual_seed(1) # # 0) 定义 input 3, output ...原创 2019-03-07 09:03:17 · 200 阅读 · 0 评论 -
pytorch_parctice_00
基本操作: # standard library import os # third-party library import torch import torch.nn as nn import torch.utils.data as Data import torchvision import matplotlib.pyplot as plt # torch.manual_seed(1...转载 2019-01-19 15:05:21 · 260 阅读 · 0 评论