![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
深度学习之TensorFlow入门、原理与进阶实战
大春SSC
这个作者很懒,什么都没留下…
展开
-
3.1y=2x线性回归
让神经网络总结出y=2x程序:import tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltplotdata = { “batchsize”:[], “loss”:[] }#存放批次值和损失值def moving_average(a, w=10):if len(a) < w:return a[:...转载 2019-06-19 18:10:35 · 168 阅读 · 0 评论 -
11 深度神经网络
11-1 tfrecodertest利用slim代码库里的函数读取TFRecord格式的数据并显示出来。准备:1.数据集下载:http://download.tensorflow.org/example_images/flower_photos.tgz参考链接:https://bbs.huaweicloud.com/forum/thread-6913-1-1.html2.数据集解压转换...转载 2019-07-09 15:14:04 · 180 阅读 · 0 评论 -
9 循环神经网络——具有记忆功能的网络
9-1 subtraction使用python编写简单循环神经网络,拟合一个退位减法的操作,观察其反向传播过程。程序:#1 定义基本函数import copy, numpy as npnp.random.seed(0) # 固定随机数生成器的种子,可以每次得到一样的值compute sigmoid nonlinearitydef sigmoid(x): # 激活函数output...转载 2019-06-28 17:07:54 · 742 阅读 · 0 评论 -
10 自编码网络——能够自动学习样本特征的网络
10-1 自编码转载 2019-07-04 12:24:36 · 320 阅读 · 0 评论 -
10 自编码网络——能够自动学习样本特征的网络(1)
10-8 变分自编码使用变分自编码模型进行模拟MNIST数据的生成。程序:#1 引入库,定义占位符import numpy as npimport tensorflow as tfimport matplotlib.pyplot as pltfrom scipy.stats import normfrom tensorflow.examples.tutorials.mnist ...转载 2019-07-04 21:46:24 · 162 阅读 · 0 评论 -
9 循环神经网络——具有记忆功能的网络(1)
9-23 yuyinchall准备一批带有文字标注的语音样本,构建BiRNN网络,通过该语料样本进行训练,实现一个能够识别语音的神经网络模型程序:import numpy as npimport timeimport tensorflow as tffrom tensorflow.python.ops import ctc_opsfrom collections import Cou...转载 2019-06-30 17:47:33 · 698 阅读 · 3 评论 -
12 对抗神经网络(GAN)
12-1 Mnistinfogan通过使用InfoGAN网络学习MNIST数据特征,生成以假乱真的MNIST模拟样本,并发现内部潜在的特征信息。程序:转载 2019-07-10 23:35:26 · 345 阅读 · 0 评论 -
12 对抗神经网络(GAN)(1)
12-7 tfrecoderSRESPCN通过使用ESPCN网络,在flower数据集上将低分辨率图片复原成高分辨率图片并与其他复原函数生成的结果进行比较。程序:#1 引入头文件,创建样本数据源import tensorflow as tffrom slim.datasets import flowersimport numpy as npimport matplotlib.pyp...转载 2019-07-10 23:56:03 · 297 阅读 · 0 评论 -
9 循环神经网络——具有记忆功能的网络(3)
基于seq2seq注意力模型实现中英文机器翻译转载 2019-07-03 14:50:12 · 296 阅读 · 0 评论 -
8 卷积神经网络——解决参数太多问题(1)
8-7 queue程序:import tensorflow as tf创建长度为100的队列queue = tf.FIFOQueue(100, “float”)c = tf.Variable(0.0) # 计数器加1操作op = tf.assign_add(c, tf.constant(1.0))操作:将计数器的结果加入队列enqueue_op = queue.enqueue©...转载 2019-06-26 22:28:58 · 1036 阅读 · 0 评论 -
4.1TensorFlow编程模型
4.1 使用sessions编写hello world:程序:import tensorflow as tfhello = tf.constant(‘Hello, TensorFlow!’) #定义一个常量sess = tf.Session() #建立一个sessionprint (sess.run(hello)) ...转载 2019-06-19 21:51:37 · 140 阅读 · 0 评论 -
4.3共享变量
4-9 get_variable和Variable的区别程序:import tensorflow as tftf.reset_default_graph()var1 = tf.Variable(1.0, name=‘firstvar’)print(“var1:”, var1.name)var1 = tf.Variable(2.0, name=‘firstvar’)print(“va...转载 2019-06-20 19:23:20 · 97 阅读 · 0 评论 -
4.4 图的基本操作
4-14 图的基本操作程序 :import numpy as npimport tensorflow as tf1 创建图的方法c = tf.constant(0.0)g = tf.Graph()with g.as_default():c1 = tf.constant(0.0)print(c1.graph)print(g)print(c.graph)g2 = tf.get...转载 2019-06-20 20:42:55 · 91 阅读 · 0 评论 -
4.5 使用TensorFlow实现分布式部署训练
在本机通过3个不同的端口,分别表示一个ps,两个worker,实现TensorFlow的分布式运算程序:import tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltplotdata = {“batchsize”: [], “loss”: []}def moving_average(a, w=10):i...转载 2019-06-20 21:02:06 · 229 阅读 · 0 评论 -
5 识别图中模糊的手写数字
从MNIST数据集中选择一幅图,让机器模拟人眼区分手写数字是几5.1导入图片和数据集程序:#1 利用tensorflow代码下载mnisthttp://yann.lecun.com/exdb/mnist/from tensorflow.examples.tutorials.mnist import input_datamnist = input_data.read_data_sets(...转载 2019-06-20 22:40:44 · 488 阅读 · 0 评论 -
6 单个神经元
6.5.1 交叉熵实验假设有一个标签labels和一个网络输出值logits(1)两次softmax实验(2)两次交叉熵(3)自建公式,将做两次softmax的值放到公式中得到正确的值程序:import tensorflow as tflabels = [[0, 0, 1], [0, 1, 0]]logits = [[2, 0.5, 6],[0.1, 0, 3]]logits_...转载 2019-06-21 21:44:40 · 225 阅读 · 0 评论 -
7 多层神经网络——解决非线性问题
7.1.1 用线性单分逻辑回归分析肿瘤是良性还是恶性的假设某肿瘤医院想用神经网络对已有的病例数据进行分类,数据的样本特征包括病人的年龄和肿瘤的大小,对应的标签为该病例是良性肿瘤还是恶性肿瘤程序:#1 生成样本集import tensorflow as tfimport matplotlib.pyplot as pltimport numpy as npfrom sklearn.uti...转载 2019-06-22 16:24:04 · 1888 阅读 · 0 评论 -
8 卷积神经网络——解决参数太多问题
8-1 卷积函数使用手动生成一个55的矩阵来模拟图片,定义一个22的卷积核,来测试tf.nn.conv2d函数里的不同参数,验证其输出结果。程序:import tensorflow as tf#1 定义输入变量[batch, in_height, in_width, in_channels] [训练时一个batch的图片数量, 图片高度, 图片宽度, 图像通道数]input = tf....转载 2019-06-26 17:51:21 · 1280 阅读 · 1 评论 -
9 循环神经网络——具有记忆功能的网络(2)
9-25 rnnwordtest通过让RNN网络对一段文字的训练学习来生成模型,最终可以使用机器生成的模型来表达自己的意思。wordstest.txt (样本,放在代码同级目录下):在尘世的纷扰中,只要心头悬挂着远方的灯光,我们就会坚持不懈地走,理想为我们灌注了精神的蕴藉。所以,生活再平凡、再普通、再琐碎,我们都要坚持一种信念,默守一种精神,为自己积淀站立的信心,前行的气力。在程序运行之前...转载 2019-06-30 22:20:41 · 1247 阅读 · 1 评论