自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

醉意流年go的博客

NLP、ML、Deep learning

  • 博客(38)
  • 资源 (4)
  • 收藏
  • 关注

原创 DCN和DCNV2(tensorflow keras实现)

推荐系统模型DCN模型的cross network部分实现

2022-12-16 11:48:21 504 1

原创 tf.keras 使用类似Dict的方式进行建模、训练并保存

tensorflow keras 自定义字典输入和字典层 训练模型

2022-08-22 14:20:11 388

原创 MRC中答案预测实现(numpy、torch、tensorflow)

MRC问答系统中答案预测

2022-07-11 11:02:01 209

原创 tensorflow 1.13 (tf 1.13)中keras设置GPU显存大小

tensorflow 1.13 中keras设置GPU使用大小

2022-06-01 13:52:02 361

原创 tf.keras 中training的使用

import tensorflow as ffrom tensorflow.keras import layers, lossesclass OneLayer(layers.Layer): def __init__(self): super(OneLayer, self).__init__() # def call(self, inputs, **kwargs): # def call(self, inputs, **kwargs): # ..

2022-02-16 15:08:45 1023

原创 tensoflow实现相对位置编码(relative position representation)

# coding:utf-8"""@author: liu@File: relative_pos_representation_RPR.py@CreateTime: 2021/8/17 """"""实现相对位置编码参考: https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/layers/common_attention.py"""import tensorflow as tfdef ge.

2021-08-19 17:05:28 882

原创 transformers获取和验证bert的中间层

# coding:utf-8"""@author: liu@File: get_tfbertmainlayer_demo.py@CreateTime: 2021/7/26 """import numpy as npimport tensorflow as tffrom transformers import TFBertModel, TFBertMainLayer, BertConfig, BertTokenizerbert_config = BertConfig.from_.

2021-07-27 11:17:14 1643

原创 tf2中feature_columns与keras model的结合使用

分为两种情况:1、tensorflow 最新高版本的情况下(比如在tf>=2.4)2、在tensorflow==2.0的情况下在tensorflow >=2.4的情况下:import tensorflow as tffrom tensorflow.keras import layersdef train_save_model(): genre_vocab_list = ["female", "male"] level_vocab_list..

2021-07-06 09:48:12 445

原创 tf 2.0 keras和feature_column的结合使用

tensorflow == 2.4# coding:utf-8"""@author: liu@File: tf_feature_col.py@CreateTime: 2021/7/5 """import tensorflow as tffrom tensorflow.keras import layersgenre_vocab_list = ["female", "male"]level_vocab_list = ["low", "middle", "up"]

2021-07-05 13:43:46 368

原创 tf.gather和tf.gather_nd的使用和区别

# coding:utf-8"""@author: liu@File: tf_gather_nd.py@CreateTime: 2021/6/17 """"""测试tf.gather和tf.gather_nd的区别和联系"""import numpy as npimport tensorflow as tfprint("tensorflow version: ", tf.__version__)data = np.arange(18).reshape((3, 2, 3).

2021-06-17 11:03:46 408

原创 tensorflow padded_batch的注意事项

tensorflow版本:1.13.11、在padded_batch中,若函数出现错误:TypeError: If shallow structure is a sequence, input must also be a sequence. Input has type: <class 'int'>. 案例如下,在以下案例中, 出现上述错误的原因是:在paddd_batch中的参数:padding_values, 如果不设置此参数,则没有问题,即此行代码更改为:...

2021-02-04 11:08:36 1056 1

原创 tensorflow dataset tfrecord的写入和读取

tensorflow的版本:1.13.1针对tensorflow 2以及上的版本,可以参考tensorflow的官方介绍:https://www.tensorflow.org/tutorials/load_data/tfrecord def create_int_feature(self, values): feature = tf.train.Feature(int64_list=tf.train.Int64List(value=list(values)))

2021-02-03 16:20:00 278

原创 keras 中lstm 和bidirectional lstm (Bilstm)的return_sequence和return_state之间的关系

import tensorflow as tftf.enable_eager_execution()embedding = tf.Variable(tf.truncated_normal((2, 3, 4)))lstm = tf.keras.layers.LSTM(units=5, return_sequences=False, return_state=False)outputs = lstm(embedding) # return_sequences=False, return_s..

2021-01-28 16:08:11 2423

原创 Asymmetric Loss For Multi-Label Classification 重现 【非对称损失函数】 tensorflow

应用场景:不平衡下的多标签和单标签多分类问题分为两部分:1、多标签分类def multi_label_asymmtric_loss_tf(labels, logits, gamma_pos=1, gamma_neg=4, clip=0.05, eps=1e-8, ): # 计算概率 caalculating probabilities logits_sigmoid = tf.nn.sigmoid(logits) logits_sigmoid_pos = logits_

2021-01-27 09:58:16 1840 3

原创 tensorflow cross entropy实现交叉熵

import tensorflow as tfprint(tf.__version__)tf.enable_eager_execution()logits = tf.Variable(tf.truncated_normal(shape=(2, 5)))labels = tf.Variable([[1, 0, 0, 0, 0], [0, 0, 0, 0, 1]], dtype=tf.float32)"""下面是实现交叉熵损失的两种方法:等价的两种方法"""# 第一种交叉熵实现方.

2021-01-25 14:39:41 98

原创 tensorflow 1.13, keras + placeholder + saved_model的混用【主要是验证一下】

共分为两步:1、训练模型并保存2、加载模型进行预测1、训练模型并保存代码如下:import tensorflow as tf # tf.version==1.13.1import numpy as npx = tf.placeholder(tf.int32, shape=(None, 100), name="x")y = tf.placeholder(tf.int32, shape=(None, ))# embeddings = tf.keras.layers..

2021-01-13 11:47:55 477

原创 tensorboard的基本使用

import tensorflow as tftf.summary.scalar("1", 1.0)tf.summary.scalar("2", 2.0)"""上述在使用了若干个tf.summary函数中记录了信息值后,需要对所有需要的记录纸进行全部的合并,需要调用tf.summary.merge_all()"""merged_all = tf.summary.merge_all()writer = tf.summary.FileWriter("logdir/", graph=tf..

2020-10-09 12:42:50 186

原创 tensorflow 实现RBFSoftmax

参考论文:RBF_softmax:Learning Deep Representative Prototypes with Radial Basis Function Softmax"""RBF_softmax:Learning Deep Representative Prototypes with Radial Basis Function Softmax交叉熵是深度学习中非常常用的一种损失,通过交叉熵学到的特征表示会有比较大的类内的多样性。因为传统的softmax损失优化的是类内.

2020-09-22 11:43:56 378

原创 验证tensorflow api可以混用

tensorflow版本:1.13.1可以确定的混用规则是:低级API(placeholder) + tf.layes.Dense之类的API可以混用混用规则:低级API(placeholder)+ keras 层 混用a = tf.placeholder(tf.float32, [None, 2], name="inputs")dense = tf.keras.layers.Dense(32)hidden = dense(a)dense_1 = tf.keras.layers.Den

2020-07-31 16:27:37 138

原创 tensorflow 实现BahdanauAttention

class BahdanauAttention(tf.layers.Layer): def __init__(self, num_units): super(BahdanauAttention, self).__init__() self.num_units = num_units self.w1 = tf.layers.Dense(num_units) self.w2 = tf.layers.Dense(num_units) .

2020-07-31 16:08:59 527

原创 tensorflow 实现weight norm

讲述权重归一化在文本在conv1d上和全连接层dense上的应用,参考了simple-effective-text-matching的实现import numpy as npimport tensorflow as tfdef gelu(x): return 0.5 * x * (1 + tf.nn.tanh(x * 0.7978845608 * (1 + 0.044715 * x * x)))def get_weight(shape, gain=np.sqrt(2), w..

2020-07-17 13:52:45 1425

原创 【AReLU: Attention-based-Rectified-Linear-Unit】 tensorflow 实现arelu激活函数

import tensorflow as tfclass TfModel(object): def __init__(self, max_len=10, vocab_size=500, embedding_size=100, alpha=0.90, beta=2.0): self.max_len = max_len self.vocab_size = vocab_size self.embedding_size = embedding_siz.

2020-07-01 14:15:03 482

原创 tensorflow L2正则化实现以及差异性(tf.nn.l2_loss、tf.nn.l2_normalize、tf.contrib.layers.l2_regularizer)

import tensorflow as tffrom tensorflow.contrib import layersa = tf.Variable([3.0, 4.0])# 第一种正则化方法aa = tf.nn.l2_normalize(a) # a中每个元素除以(平方和开2次根号), 标准的l2范数, 得到是一个shape与输入a相同的tensor# 第二种正则化方法a_l2_loss = tf.nn.l2_loss(a) # a中每个元素平方和除以2, 是一个scalar# .

2020-06-30 11:35:46 1439 2

原创 pygraphviz在win10 python3.6安装

借助于conda命令来安装:第一步:安装pygraphviz执行命令:conda install -c alubbock pygraphviz第二步:验证dot是否可用执行命令:dot -v执行以上两步,在使用pygraphviz中如出现如下错误:Format: "dot" not recognized. Use one of:, 执行第三步命令即可(如下)第三步:如果dot命令可用, 执行命令:dot -c到此安装成功...

2020-06-17 10:32:27 2901 7

原创 tensorflow serving中enable_model_warmup在部署中的使用

enable_model_warmup参数:在tensorflow serving中通过saved_model模型中自带客户端的请求来预加载模型,减少第一次的请求的延迟命名:在saved_model模型文件夹下的assert.extra文件夹,放入命名为tf_serving_warmup_requests的tf record文件即可# coding:utf-8# @author: “”# @file: tf_serving_warmup_requests_client.py# @ti.

2020-06-08 09:20:16 971

原创 tensorflow中sparse_placeholder在saved_model中保存pb模型的使用方法

# coding:utf-8# @author: liu# @file: sparse_tensor_pb.py# @time: 2020/4/3 11:00# @desc:# coding:utf-8import tensorflow as tfimport randomimport numpy as npimport osimport shutilprint...

2020-04-03 14:12:52 498

原创 NER 模型

github上的NER模型(中文)https://github.com/XierHacker/ChineseWordSegmenthttps://github.com/Determined22/zh-NER-TFhttps://github.com/baiyyang/medical-entity-recognitionhttps://github.com/hontsev/Chine...

2019-07-10 10:08:04 592

原创 深度学习中的线性代数

1、范数目的:在机器学习和深度学习中,限制模型复杂度、提升模型的泛华能力。范数(Norm)的定义:|x|p=(i|x|p)1pL1范数:即x的绝对值之和L2范数:即xi的平方和的二次方根(欧几里得范数)代码:Import numpy as npImport numpy.linalg as LAX = np.arange(0,1,0.1)X1 = LA.nor...

2018-11-04 17:09:03 483

原创 numpy常用操作

Numpy:Numerical Python的简称使用工具:numpy语言:Python3主要特点:ndarray,快速,节省空间的多维数组,提供数组化的算数运算和高级的广播功能 使用标注数学函数对整个数组的数据进行快速运算,不需要编写循环 读取或者写入磁盘上的阵列数据和操作存储器映像文件的工具 线性代数,随机数生成,以及傅里叶变换的能力 集成C、C++、Fortran代码...

2018-10-30 21:47:37 390

原创 Neo4j语法教程

neo4j简版教程create (<node-name:<label-name2>:<label-name2>......>) return <node-name>可以给一个节点创建多label的nodeeg:CREATE (dept:Dept { deptno:10,dname:"Accounting",location:"Hyd...

2018-10-30 19:26:04 3028

原创 python word2vec 判断某个词语是否在词典中

通过Python gensim训练word2vec过程中,假如得到的模型变量是word2vecModel,判断某个词语是否在训练word2vecModel的词典中,利用下面的句子:   if word in word2vecModel即可...

2018-08-08 16:56:04 8838 8

原创 自然语言处理 依存树的可视化

目标:NLP中依存树的可视化首先需要准备的工具Hanlp(借助hanlp神经网络的高性能依存句法分析器模型)Dependency Viewer可视化工具 对于一句话text,可以采用hanlp中的下图代码转化为conll格式下图是采用了一些测试句子的结果(在conll文件中以空行隔开): 在dependency View中进行展示,打开dependency View,选择File----read ...

2018-06-27 10:33:57 4015

原创 grpc python 和Java实现,相互调用

Grpc实战教程:说一下目的:实现Python变成的服务端,Java作为客户端,实现二者的通信,实现的功能:传递过来的字符串全部转换为大写 一、安装(Java和Python)1、  Python安装grpc1)      gRPC 的安装,执行命令:pipinstall grpcio2)      ProtoBuf 相关的 python 依赖库,执行:pipinstall protobuf3)  ...

2018-06-27 09:57:30 12696 6

原创 grpc Python 笔记

最近在学习rpc有关的知识,搜索之后发现grpc框架,便进行了学习,本笔记是关于Python使用的过程,以后会有java的教程。目标:实现字母的大写转换前提:安装好Python1、grpc的安装(当然也可以参考官网教程进行安装)1)      gRPC 的安装,执行命令:pipinstall grpcio2)      ProtoBuf 相关的 python 依赖库,执行:pipinstall p...

2018-05-08 17:13:03 3257

原创 win10下编译ltp4j

重现LTP4j(3.4.0)的编译:(首先安装maven和git,可以通过mvn -h 和git --version来查看是否安装成功)在D盘下新建ltp文件夹,按顺序执行下列命令:1、git init(若初始化过,可以省略此步骤)2、git clone https://github.com/HIT-SCIR/ltp4j.git3、cd ltp4j4、git checkout neoltp4j5、...

2018-04-03 18:23:25 1816 24

原创 window下编译ltp4j

Win10 下LTP4j的编译安装git和maven,可以在命令行窗口下通过git --version 和maven -h来观察是否安装成功在命令行下通过命令下载ltp4j文件:git clone https://github.com/HIT-SCIR/ltp4j.git(若出现fatal:not a git repository,则需要先执行git init再执行此命令)cd ltp4j(进入...

2018-04-03 18:18:44 1157 5

原创 ubuntu16 pytorch 源码编译安装教程

最近想玩一下pytorch框架,就在ubuntu16上安装了一下pytorch,安装官网给的安装教程,会出现httpError错误,建议从源码编译安装。1、安装anaconda3(Python3.5),这个就不介绍了从github(https://github.com/pytorch)上下载两个文件,如下图3、利用conda install libgcc, 避免出现fr

2017-10-03 12:38:51 3235

原创 Python训练Word2Vec和Doc2Vec

软件要求: Python3 gensim预料:中文语料,存在txt文件中 语料要求:在txt中每一行为一个文档doc,进行分词,分词之间用空格或者tab键隔开训练word2vec模型代码:import multiprocessingfrom gensim.models import Word2Vecfrom gensim.models.word2vec im

2017-01-05 17:39:04 2498

DependecyViewer

依存树的可视化工具,便于理解依存句法分析在NLP中的表现形式,加深对依存句法的理解

2018-06-27

weka使用教程

主要介绍了weka的一些应用界面,如何选择常见的机器学习分类算法,特征选择

2015-08-03

数据挖掘经典算法

数据挖掘中一些最常用的经典算法,对于初学者了解数据挖掘的算法有一定的了解。

2014-07-20

数据挖掘概念和技术

数据挖掘技术和概念详细讲解了在数据挖掘方面各种的入门知识,能为初学者提供很好的基础知识。

2014-07-07

空空如也

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

TA关注的人

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