11.tensorboard网络结构
- import tensorflow as tf
- from tensorflow.examples.tutorials.mnist import input_data
- # 载入数据集
- mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
- # 批次大小
- batch_size = 64
- # 计算一个周期一共有多少个批次
- n_batch = mnist.train.num_examples // batch_size
- with tf.name_scope('input'):
- # 定义两个placeholder
- x = tf.placeholder(tf.float32,[None,784], name='x-input')
- y = tf.placeholder(tf.float32,[None,10], name='y-input')
- with tf.name_scope('layer'):
- # 创建一个简单的神经网络:784-10
- with tf.name_scope('weights'):
- W = tf.Variable(tf.truncated_normal([784,10], stddev=0.1))
- with tf.name_scope('biases'):
- b = tf.Variable(tf.zeros([10]) + 0.1)
- with tf.name_scope('wx_plus_b'):
- wx_plus_b = tf.matmul(x,W)+b
- with tf.name_scope('softmax'):
- prediction = tf.nn.softmax(wx_plus_b)
- with tf.name_scope('loss'):
- # 二次代价函数
- loss = tf.losses.mean_squared_error(y, prediction)
- with tf.name_scope('train'):
- # 使用梯度下降法
- train = tf.train.GradientDescentOptimizer(0.3).minimize(loss)
- with tf.name_scope('accuracy'):
- with tf.name_scope('correct_prediction'):
- # 结果存放在一个布尔型列表中
- correct_prediction = tf.equal(tf.argmax(y,1),tf.argmax(prediction,1))
- with tf.name_scope('accuracy'):
- # 求准确率
- accuracy = tf.reduce_mean(tf.cast(correct_prediction,tf.float32))
- with tf.Session() as sess:
- # 变量初始化
- sess.run(tf.global_variables_initializer())
- writer = tf.summary.FileWriter('logs/',sess.graph)
- # # 周期epoch:所有数据训练一次,就是一个周期
- # for epoch in range(21):
- # for batch in range(n_batch):
- # # 获取一个批次的数据和标签
- # batch_xs,batch_ys = mnist.train.next_batch(batch_size)
- # sess.run(train,feed_dict={x:batch_xs,y:batch_ys})
- # # 每训练一个周期做一次测试
- # acc = sess.run(accuracy,feed_dict={x:mnist.test.images,y:mnist.test.labels})
- # print("Iter " + str(epoch) + ",Testing Accuracy " + str(acc))
11.tensorboard网络结构的更多相关文章
- tensorboard网络结构
一.tensorboard网络结构 import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data ...
- TensorFlow(六):tensorboard网络结构
# MNIST数据集 手写数字 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # ...
- Tensorflow目录
0.Tensorflow安装 1.创建会话,启动会话 2.变量 3.Fech_feed 4.线性回归 5.非线性回归 6.MNIST数据集简单分类 7.交叉熵 8.Dropout 9.正则化 10.优 ...
- 【智能家居篇】wifi网络结构(上)
转载请注明出处:http://blog.csdn.net/Righthek 谢谢! WIFI是什么.相信大家都知道,这里就不作说明了. 我们须要做的是深入了解其工作原理,包含软硬件.网络结构等.先说明 ...
- tensorflow学习框架(炼数成金网络版学习记录)
chapter1 #变量 import tensorflow as tf x = tf.Variable([1,2]) a = tf.constant([3,3]) #增加一个减法op sub = t ...
- #Deep Learning回顾#之LeNet、AlexNet、GoogLeNet、VGG、ResNet
CNN的发展史 上一篇回顾讲的是2006年Hinton他们的Science Paper,当时提到,2006年虽然Deep Learning的概念被提出来了,但是学术界的大家还是表示不服.当时有流传的段 ...
- LeNet,AlexNet,GoogleLeNet,VggNet等网络对比
CNN的发展史 上一篇回顾讲的是2006年Hinton他们的Science Paper,当时提到,2006年虽然Deep Learning的概念被提出来了,但是学术界的大家还是表示不服.当时有流传的段 ...
- deep learning 经典网络模型之Alexnet、VGG、Googlenet、Resnet
CNN的发展史 上一篇回顾讲的是2006年Hinton他们的Science Paper,当时提到,2006年虽然Deep Learning的概念被提出来了,但是学术界的大家还是表示不服.当时有流传的段 ...
- 反向传播(Back Propagation)
反向传播(Back Propagation) 通常在设计好一个神经网络后,参数的数量可能会达到百万级别.而我们利用梯度下降去跟新参数的过程如(1).但是在计算百万级别的参数时,需要一种有效计算梯度的方 ...
随机推荐
- Django 1.x版本与2.x版本 区别
django 1.x版本与2.x版本 URL区别 在django 1.x中的方式 导入的模块是'from django.conf.urls import url',urlpatterns中url对应的 ...
- 快速幂 -- cogs1437 转圈游戏
题目链接:http://cogs.pro:8081/cogs/problem/problem.php?pid=vJimmkqjW [题目描述] 思路:简单模拟,重点在于如何求这个轮数,由于k的范围过大 ...
- kube-metric在kubernetes上的部署
1.拿包 wgethttps://github.com/kubernetes/kube-state-metrics/archive/v1.7.2.tar.gz 2.tar -zxf v1.7.2.t ...
- layui checkbox , radio 清除所有选中项
方法: $(selector).prop('cjecked', false); form.render(); 使用示例: // 清除radio选中 $('input[name=ymd]').prop( ...
- SolidWorks学习笔记9 自顶向下方法
目的:制作一个轴承. 先创建一个零件作为一级控件,(草图)如下,是轴承的横截面. 创建内环. 新建一个零件,然后选择插入=>零件,选择“一级控件”零件 创建卡环,插入零件,选择一级控件 然后再旋 ...
- 基于JAVA Socket的底层原理分析及工具实现
前言 在工作开始之前,我们先来了解一下Socket 所谓Socket,又被称作套接字,它是一个抽象层,简单来说就是存在于不同平台(os)的公共接口.学过网络的同学可以把它理解为基于传输TCP/IP协议 ...
- [转帖]为何 linux 要用 tar.gz,而不用 7z 或 zip?
为何 linux 要用 tar.gz,而不用 7z 或 zip? http://embeddedlinux.org.cn/emb-linux/entry-level/201908/13-8776.ht ...
- BandingList 泛型集合数据绑定
public IList<Student> IStudent = new List<Student>(); public BindingList<Student> ...
- PAT B1036 跟奥巴马一起编程 (15)
AC代码 #include <cstdio> using namespace std; int main(){ int n = 0, m = 0; char a; scanf(" ...
- CentOS7下使用ELK搭建日志集中分析平台
应用场景: ELK实际上是三个工具的集合,ElasticSearch + Logstash + Kibana,这三个工具组合形成了一套实用.易用的监控架构,很多公司利用它来搭建可视化的海量日志分析平台 ...