
TensorFlow
BQW_
吉林大学
北京大学
目前的兴趣:自然语言处理
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【Tensorflow】多分类问题的Precision、Recall和F1计算及Tensorflow实现
一、二分类问题的Precision、Recall、F1网络上关于Precision、Recall和F1的介绍有很多,因此这里只作简单回顾。在二分类问题中,根据真实类别和预测类别的组合可以分为四中情况,分别是TP(True Positive)、FP(False Positive)、TN(True Negative)、FN(False Negative)。如下图:那么Precision表示所有...原创 2019-12-06 18:33:41 · 8471 阅读 · 0 评论 -
【TensorFlow】TensorBoard监控网络运行
import tensorflow as tf# 加载数据from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('/tmp/data',one_hot=True)Extracting /tmp/data/train-images-idx3-ubyte.gzE...原创 2018-12-03 22:47:46 · 788 阅读 · 0 评论 -
【TensorFlow】使用卷积神经网络对MNIST进行分类
import osimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data加载数据mnist = input_data.read_data_sets('../input',one_hot=True)Extracting ../input/train-images-idx3-uby...原创 2018-12-09 22:19:05 · 484 阅读 · 0 评论 -
【TensorFlow】使用LSTM对MNIST进行分类
import tensorflow as tfimport numpy as npfrom tensorflow.contrib import rnnfrom tensorflow.examples.tutorials.mnist import input_data加载数据mnist = input_data.read_data_sets('/tmp/data',one_hot=Tru...原创 2018-12-09 22:41:40 · 606 阅读 · 0 评论 -
【TensorFlow】实现Basic RNN
该模型是一个Seq2Seq的模型:输入:(0,1)序列;例如x = (1,1,1,0,0,0,1,1)标签:输出(0,1)序列右移若干位后的序列;例如将x右移2位后,y=(0,0,1,1,1,0,0,0)因此该模型的作用是给定一个(0,1)序列,预测其右移若干位后的序列。import numpy as npimport tensorflow as tfimport matplotl...原创 2018-12-09 23:22:00 · 525 阅读 · 0 评论 -
【TensorFlow】深度循环神经网络_StackedLSTM
1.该模型是一个Seq2Seq的模型:输入:(0,1)序列;例如x = (1,1,1,0,0,0,1,1)标签:输出(0,1)序列右移若干位后的序列;例如将x右移2位后,y=(0,0,1,1,1,0,0,0)2.该模型的作用是给定一个(0,1)序列,预测其右移若干位后的序列。3.该模型是一个深度的LSTM,其将3个LSTM堆叠到一起。import numpy as npimport...原创 2018-12-22 10:06:23 · 1535 阅读 · 0 评论 -
【TensorFlow】实现动态LSTM(Dynamic LSTM)
1.该模型是一个Seq2Seq的模型:输入:(0,1)序列;例如x = (1,1,1,0,0,0,1,1)标签:输出(0,1)序列右移若干位后的序列;例如将x右移2位后,y=(0,0,1,1,1,0,0,0)2.该模型的作用是给定一个(0,1)序列,预测其右移若干位后的序列。3.该模型是一个深度的LSTM,其将3个LSTM堆叠到一起。4.该模型使用dynamic_rnn来实现动态LS...原创 2018-12-22 23:07:25 · 4151 阅读 · 0 评论 -
【Tensorflow】用于构建大规模分布式模型的高阶API(一)_Dataset
import numpy as npimport pandas as pdimport tensorflow as tf一、介绍在低阶API中通常我们使用feed_dict将数据输入到模型中,但是这样的速度对于大型数据集来说很慢,因此tensorflow提供了高级API–Dataset,其使用内置的pipeline高效的将数据输入到模型中。Dataset可以看作是相同类型“元素”的有序...原创 2019-06-06 13:36:50 · 614 阅读 · 1 评论 -
【Tensorflow】用于构建大规模分布式模型的高阶API(二)_FeatureColumn
import numpy as npimport pandas as pdimport tensorflow as tf一、介绍在传统的机器学习中特征工程是一个重要的部分,在深度学习中有时也需要进行特征工程,因此Tensorflow提供FeatureColumn API为特征工程提供支持。Feature column是原始数据与estimator模型之间的桥梁,它把各种类型的原始数据转换...原创 2019-06-06 23:16:04 · 1667 阅读 · 0 评论 -
【Tensorflow】用于构建大规模分布式模型的高阶API(三)_使用预定义Estimator
import numpy as npimport pandas as pdimport tensorflow as tffrom sklearn import datasetsfrom sklearn.model_selection import train_test_split一、Tensorflow的多层次编程API官方建议:使用Estimator API和dataset AP...原创 2019-06-07 00:34:44 · 1075 阅读 · 0 评论 -
【Tensorflow】用于构建大规模分布式模型的高阶API(四)_Estimator模型的保存
import numpy as npimport pandas as pdimport tensorflow as tffrom sklearn import datasetsfrom sklearn.model_selection import train_test_splitiris = datasets.load_iris()train_x,test_x,train_y,tes...原创 2019-06-07 01:30:00 · 1168 阅读 · 0 评论 -
【TensorFlow】用于构建大规模分布式模型的高阶API(五)_自定义Estimator
import numpy as npimport pandas as pdimport tensorflow as tffrom sklearn import datasetsfrom sklearn.model_selection import train_test_split一、自定义Estimator的步骤1.创建一个或多个输入函数;2.定义模型的Feature colum...原创 2019-06-08 12:04:30 · 815 阅读 · 0 评论 -
【Tensorflow】用于构建大规模分布式模型的高阶API(六)_自定义Estimator进行文本分类
import numpy as npimport pandas as pdimport tensorflow as tfimport datetimefrom keras.preprocessing.text import Tokenizerfrom keras.preprocessing.sequence import pad_sequencesfrom keras.utils im...原创 2019-06-09 01:12:53 · 1215 阅读 · 0 评论 -
【TensorFlow】使用BasicRNNCell实现RNN
该模型是一个Seq2Seq的模型:输入:(0,1)序列;例如x = (1,1,1,0,0,0,1,1)标签:输出(0,1)序列右移若干位后的序列;例如将x右移2位后,y=(0,0,1,1,1,0,0,0)因此该模型的作用是给定一个(0,1)序列,预测其右移若干位后的序列。import numpy as npimport tensorflow as tfimport matplotl...原创 2018-12-12 23:47:40 · 926 阅读 · 0 评论 -
【TensorFlow】使用双向LSTM对MNIST进行分类
import tensorflow as tfimport numpy as npfrom tensorflow.contrib import rnnfrom tensorflow.examples.tutorials.mnist import input_data加载数据mnist = input_data.read_data_sets('/tmp/data',one_hot=Tru...原创 2018-12-12 23:09:00 · 1870 阅读 · 0 评论 -
【TensorFlow】:一个二分类的例子
import tensorflow as tffrom numpy.random import RandomState# 定义训练数据batch的大小batch_size = 8# 随机初始化神经网络的参数w1 = tf.Variable(tf.random_normal([2,3],stddev=1,seed=1)) # 3*2的权重矩阵w2 = tf.Variable(tf.r...原创 2018-10-20 22:50:35 · 2274 阅读 · 0 评论 -
【TensorFlow】:获取默认计算图与创建新的计算图
获取默认计算图:tf.get_default_graph()import tensorflow as tfa = tf.constant([1.0,2.0],name='a')b = tf.constant([2.0,3.0],name='b')result = a+b# a.graph获取张量a所属的计算图# tf.get_default_graph()获取默认的计算图print(...原创 2018-10-20 23:27:00 · 4200 阅读 · 0 评论 -
【TensorFlow】:激活函数
import tensorflow as tfsess = tf.InteractiveSession()TensorFlow提供了7中激活函数1.ReLUf(x)=max(x,0)f(x)=max(x,0)f(x)=max(x,0)print(tf.nn.relu(3.5).eval())print(tf.nn.relu(-1).eval())print(tf.nn.relu(7...原创 2018-10-21 00:20:57 · 758 阅读 · 0 评论 -
【TensorFlow】:损失函数
关于交叉熵的文章关于softmax函数的文章import numpy as npimport tensorflow as tfsess = tf.InteractiveSession()一、交叉熵1.多分类中的Softmax函数在多分类的神经网络中,通常在最后一层接一个softmax层。对于n分类问题,softmax层就有n个结点,每个结点输出的就是该类别的概率.例如5分类的问...原创 2018-10-21 01:53:23 · 739 阅读 · 0 评论 -
【TensorFlow】使用TensorFlow执行K-Means
import numpy as npimport tensorflow as tffrom tensorflow.contrib.factorization import KMeans加载数据from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("/tmp/...原创 2018-11-18 22:21:11 · 1076 阅读 · 0 评论 -
【TensorFlow】:Eager Mode(动态图模式)
TensorFlow的Eager模型,也可以看做是动态图模型。该模型下不需要先构造图,然后再使用Session.run(),而是可以得到即时的反馈。这样在研究和开发时会更加符合直觉。import numpy as npimport tensorflow as tf设置eager modetf.enable_eager_execution()tfe = tf.contrib.eager...原创 2018-11-17 21:04:59 · 5232 阅读 · 2 评论 -
【TensorFlow】使用TensorFlow实现线性回归
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt参数learning_rate = 0.01training_epochs = 1000display_step = 50生成数据X_train = np.array([3.3,4.4,5.5,6.71,6.93,4.168,9.779...原创 2018-11-17 21:56:33 · 585 阅读 · 0 评论 -
【TensorFlow】使用TensorFlow的Eager API实现线性回归
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt开启eager模式tf.enable_eager_execution()tfe = tf.contrib.eager参数learning_rate = 0.01training_epochs = 1000display_step = ...原创 2018-11-17 22:29:13 · 603 阅读 · 0 评论 -
【TensorFlow】使用TensorFlow实现LR
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltload datafrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("/tmp/data/", one_hot...原创 2018-11-17 23:04:51 · 5979 阅读 · 0 评论 -
【TensorFlow】使用TensorFlow的Eager API实现LR
import tensorflow as tf开始eager模式tf.enable_eager_execution()tfe = tf.contrib.eager加载数据from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("/tmp/data/", o...原创 2018-11-18 00:11:13 · 723 阅读 · 0 评论 -
【TensorFlow】使用Tensorflow实现KNN
import numpy as npimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets("/tmp/data/", one_hot=True)Extracting /tmp/data/train-images-...原创 2018-11-18 00:41:23 · 1363 阅读 · 5 评论 -
【TensorFlow】使用Tensorboard绘制网络结构
import tensorflow as tf# 加载数据from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('/tmp/data',one_hot=True)Extracting /tmp/data/train-images-idx3-ubyte.gzE...原创 2018-11-29 22:43:13 · 4068 阅读 · 0 评论 -
【TensorFlow】使用全连接网络+dropout对MNIST进行分类
import tensorflow as tf# 加载数据from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets('/tmp/data',one_hot=True)Extracting /tmp/data/train-images-idx3-ubyte.gzE...原创 2018-11-26 22:54:20 · 2165 阅读 · 0 评论 -
【TensorFlow】基本用法
一、TensorFlow简介1.TensorFlow是编程系统,使用图来表示计算任务。图中的结点被称为op,表示一个操作。一个op接收0个或多个Tensor进行计算,计算后输出0个或多个Tensor。2.一个TensorFlow图描述了一个计算的过程,但是真正执行计算需要将图中Session中启动。Session会将图中的op分发到诸如CPU或GPU之类的设备上。二、构造计算图1.构建图的...原创 2018-10-19 19:37:21 · 754 阅读 · 0 评论