tensorflow
普通网友
这个作者很懒,什么都没留下…
展开
-
深度学习数据归一化的方法
normalization的介绍详细介绍LNBN的tensorflow调用方法CNN使用BN方法BN是对同一batch的样本进行归一化(使用高斯归一化方法)BN是同一个batch的样本进行归一化如果batch特别小的时候就会出现不稳定情况BN不能对长度大小不一致的RNN进行处理,因为均值这些都向量长度不一样,不能得到均值LN针对同一个样本里面进行高斯归一化就可以解决这个...原创 2020-01-16 14:30:27 · 866 阅读 · 0 评论 -
tensorflow dense的用法
学习链接在不使用dense的时候可以使用下面的方法生成全连接 attention_w = tf.Variable(tf.truncated_normal([hidden_size, attention_size], stddev=0.1), name='attention_w') attention_b = tf.Variable(tf.constant(0.1,...原创 2019-11-05 19:42:08 · 897 阅读 · 0 评论 -
cuda指定python使用GPU命令
学习链接原创 2019-10-31 10:15:15 · 1520 阅读 · 0 评论 -
tensorflow:OOM when allocating tensor with shape[225,256,256,36] and type float on /job:localhost/re
解决办法解决可以使得batch size变小原创 2019-10-31 10:11:11 · 3508 阅读 · 1 评论 -
tensorflow编程思考
1.bilstm的output的len是2,是两个lstm的输出结果,所以fc_w = tf.Variable(tf.truncated_normal([hidden_size*2, num_classes], stddev=0.1), name='fc_w') fc_b = tf.Variable(tf.zeros([num_classes]), name='fc_b')self.log...原创 2019-10-24 16:45:57 · 154 阅读 · 0 评论 -
tensorflow中tf.layers.dense学习
import ioimport numpy as npimport tensorflow as tfinputs=tf.ones([2,3])a=tf.layers.dense(inputs,4)with tf.Session() as sess: init = tf.global_variables_initializer() sess.run(init) print(ses...原创 2019-05-20 18:40:03 · 614 阅读 · 0 评论 -
Tensorflow中tf.ConfigProto()详解
#-*-coding:utf8-*-import osimport pickleimport itertoolsfrom collections import OrderedDictimport tensorflow as tfimport numpy as npfrom model import Modelfrom loader import load_sentences, u...转载 2019-01-17 16:23:51 · 1446 阅读 · 1 评论 -
tensorflow中的sess.run()方法详解
run()方法详解链接feed_dict={y:3}把3赋值给y,当次计算有效。在lstm和cnn进行train和predictdef run_step(self, sess, is_train, batch): """ :param sess: session to run the batch :param is_train: a...原创 2019-01-17 19:50:36 · 33769 阅读 · 5 评论 -
textcnn对文字进行编码并且对句子进行转化
编码学习链接# -*- coding: utf-8 -*-from tensorflow.contrib import learnimport numpy as nps = ['我 可以 跟 在 你 身后 像 影子 追着 光 梦游', '我 可以 等 在 这 路口 不管 你 会不会 经过']max_document_length = 11vocab_processor =...转载 2019-01-22 13:36:03 · 520 阅读 · 0 评论 -
tensorflow实现attention
import tensorflow as tfdef attention(inputs, attention_size, time_major=False, return_alphas=False): """ Attention mechanism layer which reduces RNN/Bi-RNN outputs with Attention vector....转载 2018-09-04 15:32:26 · 3485 阅读 · 0 评论 -
tesorflow实现(a+b)*c
import tensorflow as tfa=tf.constant([1, 2, 3])b=tf.constant([3, 2, 1])c=tf.constant([[1],[2],[3]])z=tf.multiply(tf.add(a,b),c)tf.initialize_all_variables()with tf.Session() as sess: print(ses...原创 2018-07-16 14:26:45 · 894 阅读 · 1 评论 -
tensorflow中shape,get_shape,reshape,set_shape的对比
shape和get_shapeimport tensorflow as tfx1 = tf.placeholder(tf.int32,shape=[2,2])print(tf.shape(x1))print(x1.get_shape())输出结果:"C:\Program Files\Anaconda3\python.exe" D:/pycharmprogram/tensorflow_lea...原创 2018-07-16 13:33:26 · 6405 阅读 · 0 评论 -
tf.nn.embedding_lookup函数的用法
学习连接转载 2018-06-13 15:16:43 · 219 阅读 · 0 评论 -
Tensorflow之softmax学习
实验代码如下:# 看懂这个例子import tensorflow as tfimport tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets("C:\\tmp\\tensorflow\\mnist\\input_data", one_hot=True)pri原创 2017-06-01 13:21:06 · 696 阅读 · 0 评论 -
Tensorflow中mnist数据使用CNN训练
实验代码如下:import tensorflow as tfimport tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets('MNIST_data', one_hot=True)sess = tf.InteractiveSession()def weigh原创 2017-06-01 15:35:33 · 525 阅读 · 0 评论 -
tensorflow中eval错误解决方法
错误解决方案链接eval(session=sess)在调用eval的时候添加session=sess可以进行解决转载 2019-01-22 13:39:12 · 1139 阅读 · 0 评论 -
使用lstm对计算句子相似度解决FAQ
算法介绍开源代码地址不同点介绍转载 2019-01-29 16:48:50 · 3095 阅读 · 0 评论 -
GPU使用
登录有GPU的机器。然后使用docker进入安装了cuda的环境。查看gpu使用状况查询命令介绍启动代码中选择gpu进行运算import osos.environ['CUDA_VISIBLE_DEVICES'] = '1'...原创 2019-07-21 12:46:18 · 281 阅读 · 0 评论 -
tensorflow中的InvalidArgumentError (see above for traceback): indices[1] = 10 is not in [0, 10)
InvalidArgumentError (see above for traceback): indices[1] = 10 is not in [0, 10)lookup的时候出现10的index,但是embedding中没有10对应的向量就会报错原创 2019-07-24 17:44:24 · 5408 阅读 · 9 评论 -
gan理论学习
理论学习链接gan的原理详解gan是让生成模型尽可能生成最近似的图像,让判别模型对生成图片和原始图片的判别准确率比较高,所以损失函数定义为...转载 2019-07-14 15:59:27 · 147 阅读 · 0 评论 -
textcnn实战代码
代码详解self.embedded_chars_expanded = tf.expand_dims(self.embedded_chars, -1)因为卷积层参数是filter_shape = [filter_size, embedding_size, 1, num_filters] W = tf.Variable(tf.truncated_norm...转载 2019-06-24 20:14:19 · 729 阅读 · 0 评论 -
transformer理论和代码初步学习
理论学习链接transformer代码Q = tf.layers.dense(queries, d_model, use_bias=False) # (N, T_q, d_model) K = tf.layers.dense(keys, d_model, use_bias=False) # (N, T_k, d_model) V = tf.layers.d...转载 2019-05-21 12:33:20 · 221 阅读 · 0 评论 -
dataset中shuffle()、repeat()、batch()学习
import numpy as npimport tensorflow as tfdef data_generator(): dataset = np.array(range(5)) for d in dataset: yield d#data_generator是一个迭代函数[0,1,2,3,4]dataset = tf.data.Dataset.from_generat...原创 2019-05-09 13:59:30 · 1934 阅读 · 1 评论 -
BERT学习链接
简书网友讲解BERTBERT开源代码tensorflow版BERT+BILSTM+CRF进行实体识别BERT+BILSTM+CRF实体识别代码知乎BERT详解原始论文下载ELMO算法学习张俊林全面详细介绍BERTBERT里面只是使用了transform里面的一个encode模型(包含multiheads)并没有使用transform,而且下游任务确实是根据图里面的获...转载 2019-02-12 13:37:03 · 547 阅读 · 0 评论 -
Tensorflow之models中lstm测试
在Tensorflow中测试lstm 首先要下载数据数据存储在\simple-examples\data中 然后下载代码,代码存储在models-master\tutorials\rnn\ptb中 在python中运行ptb_word_lm.py,报编码错误时候删除decode(‘utf-8’) 然后运行ptb_word_lm.py 运行命令为 cd models/tutorials/r原创 2017-06-02 18:16:47 · 2165 阅读 · 0 评论 -
Tensorflow基础知识学习
下面网页详细介绍了Tensorflow的基础知识https://www.tensorflow.org/get_started/get_started转载 2017-06-06 13:38:44 · 347 阅读 · 0 评论 -
Tensorflow之核心教程
TensorFlow核心教程 导入Tensorflow TensorFlow程序的规范导入声明如下:import tensorflow as tf这使Python可以访问TensorFlow的所有类,方法和符号。大多数文档假定您已经完成了。 计算图您可能会认为TensorFlow Core程序由两个独立部分组成:1.构建计算图。 2.运行计算图。 计算图形是一系列排列成节点的图形Tenso转载 2017-06-06 14:05:15 · 802 阅读 · 0 评论 -
tf.nn.xw_plus_b学习
#-*-coding:utf8-*-import tensorflow as tfx=[[1, 2, 3],[4, 5, 6]]w=[[ 7, 8],[ 9, 10],[11, 12]]b=[[3,3],[3,3]]result=tf.nn.xw_plus_b(x,w,[3,3])init_op = tf.initialize_all_variables()with tf.Se原创 2018-01-24 14:57:34 · 3081 阅读 · 0 评论 -
ValueError: setting an array element with a sequence.
tensorflow程序在ubuntu下面没有报错而在windows下面报错,主要原因是windows下应该使用UTF-8的bom形式,BOM是windows的独有格式,在BOM文件都头部有标签可以显示文件的编码。所以设置无bom格式的时候会出现文件开头是乱码。就会导致出现ValueError: setting an array element with a sequence.原创 2017-12-05 14:24:06 · 997 阅读 · 0 评论 -
windows7下使用GPU训练tensorflow深度学习模型
windows7先看一下自己有没有GPU,计算机->属性->设备管理器->显示适配器看到自己的显卡,然后查看是否支持GPU运算。 如果支持GPU运算就可以安装CUDA 下载地址如下: cuda8下载地址 cudnn下载地址 tensorflow1.3需要cuda8+cudann8+v6.0+GPU版tensorslow 下载cuda8之后安装,解压cudann8把cu...原创 2017-11-30 16:53:49 · 2457 阅读 · 0 评论 -
tensorflow学习fully_connected_feed.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# Yo原创 2017-10-17 16:00:43 · 753 阅读 · 0 评论 -
tensorflow中变量的保存和加载
TensorFlow中我们可以保存全部变量也可以保存部分变量 下面是保存全部变量的代码(保存变量的时候要全部初始化)import tensorflow as tf# Create some variables.v1 = tf.Variable('v1', name="v1")v2 = tf.Variable('v2', name="v2")# Add an op to initialize转载 2017-10-24 13:17:29 · 1615 阅读 · 1 评论 -
tensorflow中lstm学习
cell的原理,主要讲述lstm中cell里面的三个门,输入门,遗忘门,输出门,详细介绍如下:http://blog.csdn.net/u014595019/article/details/52605693主要讲解lstm输入的数据格式,以及参数。 batch_size定义一次输入的词的个数。 输入的单词都是用id代替,然后需要转化成one_hot向量。 损失函数使用交叉熵,跟cnn类似。转载 2017-10-23 11:10:05 · 406 阅读 · 0 评论 -
MINST数据TensorFlow中CNN测试
import input_datamnist = input_data.read_data_sets('MINST_DATA', one_hot=True)import tensorflow as tfsess = tf.InteractiveSession()x = tf.placeholder("float", shape=[None, 784])y_ = tf.placeholder原创 2017-10-10 21:47:55 · 641 阅读 · 0 评论 -
MINST数据softmax进行数字识别
1.首先安装TensorFlow最好Python在3.5以上。 2.下载intput_data.py进行下载minst数据和使用数据。 3.修改intput_data.py中的错误。return numpy.frombuffer(bytestream.read(4), dtype=dt)修改为下面return numpy.frombuffer(bytestream.read(4), dtyp原创 2017-10-10 20:20:06 · 788 阅读 · 0 评论 -
深度学习lstm防止过拟合之dropout
一般我们使用L1和L2进行正则化防止过拟合,在深度学习中我们也可以使用dropout进行正则化。http://www.cnblogs.com/santian/p/5457412.htmldropout是临时删除一部分神经元,梯度下降更新其他神经元的权值。然后下次临时删除其他的神经元同样进行这样的操作,这样就可以防止过拟合。转载 2017-10-18 15:02:51 · 19414 阅读 · 0 评论 -
Tensorflow官网lstm例子
数据集下载地址:http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz代码下载地址:https://www.tensorflow.org/tutorials/recurrent修改代码设置data_path为数据集下面的data文件夹。原创 2017-10-18 11:28:25 · 2697 阅读 · 0 评论 -
tf.diag_part学习
diag_part( input, name=None)返回张量的对角线部分。该操作返回与该diagonal部分的张量input。该diagonal部分计算如下:假设input有尺寸[D1,…, Dk, D1,…, Dk],那么输出是等级的张量,k其尺寸为[D1,…, Dk]:diagonal[i1,…, ik] = input[i1, …, ik, i1,…, ik]。 例如:原创 2017-09-25 10:34:43 · 9059 阅读 · 2 评论 -
Tensorflow基础学习
定义两个常量相乘import tensorflow as tf# 创建一个常量 op, 产生一个 1x2 矩阵. 这个 op 被作为一个节点# 加到默认图中.## 构造器的返回值代表该常量 op 的返回值.matrix1 = tf.constant([[3., 3.]])# 创建另外一个常量 op, 产生一个 2x1 矩阵.matrix2 = tf.constant([[...原创 2017-06-06 13:22:18 · 284 阅读 · 0 评论 -
tensorflow中的reduce系列学习
reduce_sum()import tensorflow as tfimport numpy as nparray=np.array([[1,2],[3,4]])a=tf.reduce_sum(array,axis=0)#初始化,在run之前必须进行的init = tf.initialize_all_variables()#创建session以便运算sess = tf.Sessio...原创 2018-05-14 14:29:24 · 898 阅读 · 0 评论