自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 文本摘要-transformers

1.数据准备import sysimport osimport numpy as npimport textwrapwrapper = textwrap.TextWrapper(width=70)import traxfrom trax import layers as tlfrom trax.fastmath import numpy as jnp# to print the entire np arraynp.set_printoptions(threshold=sys.

2020-10-27 22:37:40 1520

原创 BLEU and ROUGE

1.BLEUreference = "The NASA Opportunity rover is battling a massive dust storm on planet Mars."candidate_1 = "The Opportunity rover is combating a big sandstorm on planet Mars."candidate_2 = "A NASA rover is fighting a massive storm on planet Mars."

2020-10-27 17:23:59 442

原创 NMT with Attention

1.数据准备termcolor.colered 对输出进行染色,凸显。colored(f"tokenize('hello'): ", 'green')from termcolor import coloredimport randomimport numpy as npimport traxfrom trax import layers as tlfrom trax.fastmath import numpy as fastnpfrom trax.supervised impor..

2020-10-27 16:54:00 1139 1

原创 POS标记——HMM模型

1.数据准备from utils_pos import get_word_tag, preprocess import pandas as pdfrom collections import defaultdictimport mathimport numpy as npwith open("WSJ_02-21.pos", 'r') as f: training_corpus = f.readlines()with open("hmm_vocab.txt", 'r') as

2020-10-15 23:12:19 872

原创 自动补齐

1.数据准备import refrom collections import Counterimport numpy as npimport pandas as pddef process_data(file_name): """ Input: A file_name which is found in your current directory. You just have to read it in. Output: wor

2020-10-15 22:27:47 324

原创 利用LSTM实现NER

1.数据及库的准备#!pip -q install trax==1.3.1import trax from trax import layers as tlimport os import numpy as npimport pandas as pdfrom utils import get_params, get_vocabimport random as rnd# set random seeds to make this notebook easier to replic

2020-10-15 14:42:32 796

原创 机器翻译(english to french)&LSH

1.预处理和数据获取import pdbimport pickleimport stringimport timeimport gensimimport matplotlib.pyplot as pltimport nltkimport numpy as npimport scipyimport sklearnfrom gensim.models import KeyedVectorsfrom nltk.corpus import stopwords, twitter_sam

2020-09-28 23:25:07 749

原创 哈希表

1.单值的hash tabledef basic_hash_table(value_l, n_buckets): def hash_function(value, n_buckets): return int(value) % n_buckets hash_table = {i:[] for i in range(n_buckets)} # Initialize all the buckets in the hash table as empty l

2020-09-28 19:11:28 160

原创 PCA降维

def compute_pca(X, n_components=2): """ Input: X: of dimension (m,n) where each row corresponds to a word vector n_components: Number of components you want to keep. Output: X_reduced: data transformed in 2 dims/columns.

2020-09-28 18:34:34 171

原创 朴素贝叶斯——情感分类

1.数据集的获取与处理同logisti回归中所用方法from utils import process_tweet, lookupimport pdbfrom nltk.corpus import stopwords, twitter_samplesimport numpy as npimport pandas as pdimport nltkimport stringfrom nltk.tokenize import TweetTokenizerfrom os import getc

2020-09-28 17:05:51 393

原创 logistic regression——情感分类

1.数据集的准备2.文本预处理正则表达式提取文本nltk.tokennize分词去除标点和stopwordsstemming提取词的主干3.提取特征生成词频字典利用词频字典对每条tweet生成特征向量x[bias,pos,neg]4.logistic回归模型def gradientDescent(x, y, theta, alpha, num_iters): ''' Input: ...

2020-09-28 16:10:16 563

原创 构建RNN、LSTM

1.导入包import numpy as npfrom rnn_utils import *2.构建RNNdef rnn_cell_forward(xt, a_prev, parameters): """ Implements a single forward step of the RNN-cell as described in Figure (2) Arguments: xt -- your input data at timestep "t",

2020-09-11 15:06:06 318

原创 梯度检查

1.导入包import numpy as npfrom testCases import *from gc_utils import sigmoid, relu, dictionary_to_vector, vector_to_dictionary, gradients_to_vector2.1维梯度检查def forward_propagation(x, theta): """ Implement the linear forward propagation (

2020-09-11 14:26:57 305

原创 正则化的使用

1.导入数据集import numpy as npimport matplotlib.pyplot as pltfrom reg_utils import sigmoid, relu, plot_decision_boundary, initialize_parameters, load_2D_dataset, predict_decfrom reg_utils import compute_cost, predict, forward_propagation, backward_propaga

2020-09-11 14:19:43 481

原创 多隐层神经网络

多隐层神经网络步骤:1.定义网络结构,初始化,包括参数和隐藏层数和单元数 def initialize_parameters_deep(layer_dims): """ Arguments: layer_dims -- python array (list) containing the dimensions of each layer in our network Returns: parameters -- python ...

2020-09-11 14:02:45 904

原创 单隐层神经网络

单隐层神经网络步骤:1. 准备数据集,可以从sklearn导入X, Y = load_planar_dataset()# Visualize the data:plt.scatter(X[0, :], X[1, :], c=Y, s=40, cmap=plt.cm.Spectral);2. 定义模型结构,例如隐藏层的单元数def layer_sizes(X, Y): """ Arguments: X -- input dataset of sh..

2020-09-11 14:02:29 968

原创 Logistic 回归

Logistic 回归的步骤可以划为以下几步:1. 准备数据:标准化数据,如图片可以reshape成(n_w*n_h*3,1),不同维度的数据进行归一化等等;2. 做好服务模型准备,例如权重的初试化,包括随机初始化(np.random.rand)或零值初始化(np.zeros)等方法,还有sigmoid函数;def sigmoid(z): """ Compute the sigmoid of z Arguments: z -- A scalar or nump

2020-09-11 14:02:04 807

原创 MLP的初始化

1.导入数据集import numpy as npimport matplotlib.pyplot as pltimport sklearnimport sklearn.datasetsfrom init_utils import sigmoid, relu, compute_loss, forward_propagation, backward_propagationfrom init_utils import update_parameters, predict, load_datase

2020-09-11 14:01:37 1653

空空如也

空空如也

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

TA关注的人

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