一、基本概念
1、stochastic gradient descent(SGD):随机梯度下降,不是每次迭代参数的计算都使用全部的数据,而是取一部分(一个patch)进行计算。
2、epoch:把所有训练数据完整的过一遍。
3、step_num:过一遍需要的训练的次数。
4、patch:每次进行梯度训练时,使用的数据子集
5、泛逼近定理 “Universal approximation theorem”, 一个隐藏层可以任意逼近连续函数
二、tensorflow基础
1、用计算图描述分布式计算任务,每个session有个默认graph
2、op 是graph的节点,描述计算操作
3、常量是op,取数据也是op
4、placeholder 实现类似于模板渲染的效果,每次迭代时可以塞入数据集
5、variable 用于在不同的run周期中保持变量,可以用来存神经网络的权值
三、API
reduce_sum 求和,默认所有数据, 0表示按着列计算, 1表示按着行
reduce_max 求最大值
reduce_mean 均值
truncated_normal 截断的正态分布, stddev是标准差
sparse_softmax_cross_entropy_with_logits 把softmax计算与cross entropy计算放到一起,用来提高程序的运行速度
nn.in_top_k() 判断预测结果是否正确。函数本来的意义为判断label是不是在logits 的前k大的值,返回一个布尔值。
四、各个模块
TensorBoard 可视化计算图,计算状态,有web的ui
tf.contrib.learn 高层的模块,实现数据集、填充、训练、评估等功能
模型中间结果的保存和恢复
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
all_saver.save(sess, 'data.chkp')
模型的权重是保存在 .chkp 文件中,模型的图是保存在 .chkp.meta 文件中。
saver = tf.train.import_meta_graph('results/model.ckpt-1000.meta')
graph = tf.get_default_graph()
global_step_tensor = graph.get_tensor_by_name('loss/global_step:0')
train_op = graph.get_operation_by_name('loss/train_op')
hyperparameters = tf.get_collection('hyperparameters')
with tf.Session() as sess:
# To initialize values with saved data
saver.restore(sess, 'results/model.ckpt-1000-00000-of-00001')
print(sess.run(global_step_tensor)) # returns 1000
相关推荐
课程分享——TensorFlow实战BERT(附赠:TensorFlow1.X升级TensorFlow2.X),完整版视频教程下载。 TensorFlow实战BERT课程目录: 第1章 BERT简介 第2章 向量层是怎么来的? 第3章 注意力机制 第4章 Transformer_...
Mastering TensorFlow 1.x_Advanced machine learning and deep learning concepts using TensorFlow 1.x and Keras-Packt Publishing(2018) Google’s TensorFlow has become a major player and a go-to tool for...
关于tensorflow一层神经网络的训练代码,可以熟知整个训练流程
Mastering TensorFlow 1.x Code Notes
tensorflow1.x入门与实战代码_,tensorflow2.0运行1.0代码,Python源码.rar
Machine Learning with TensorFlow 1.x 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
TensorFlow-1x-Deep-Learning-Cookbook-code.zip TensorFlow 1.x Deep Learning Cookbook-pdf.zip pdf的代码部分乱码的,所以,把作者的代码也放在一起下载。CSDN现在必须要分下载真low,若因在他出下载的pdf中代码...
Machine Learning with TensorFlow 1.x Copyright © 2017 Packt Publishing 学习Tensorflow的入门教材,非常不错,原版电子版,看着舒服
TensorFlow 1.x Deep Learning Co - Antonio Gulli,深度学习经典入门书籍
TensorFlow 1.x Deep Learning Cookbook 配套代码 TensorFlow 1.x Deep Learning Cookbook 配套代码 TensorFlow 1.x Deep Learning Cookbook 配套代码
深度学习框架Tensorflow1版本的入门与实战代码
tensorflow一个经典的验证码训练例子,可识别验证码,很好的哟。
TensorFlow 1.x Deep Learning Cookbook 的公开版本,书里面的代码附加了压缩包的链接文件里面,比原版感觉要清楚。这本书很适合学习TensorFlow,值得推荐
tensorflow1.x入门与实战代码_,tensorflow2.0运行1.0代码,Python源码
TensorFlow 1.x Deep Learning Cookbook 原版电子书+配套代码!