Tensorflow学习教程------Fetch and Feed
#coding:utf-8
import tensorflow as tf
#Fetch
input1 = tf.constant(3.0)
input2 = tf.constant(1.0)
input3 = tf.constant(5.0)
add = tf.add(input1,input2)
mul = tf.multiply(input1,add)
with tf.Session() as sess:
result = sess.run([mul,add]) #同时运行两个op
print (result)
结果
Total memory: 10.91GiB
Free memory: 10.21GiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:03:00.0)
[12.0, 4.0] Feed的字面意思是喂养,流入。在tensorflow里面就是说先声明一个或者几个tensor,先用占位符给他们留几个位置,等到后面run的时候,再以其他形式比如字典的形式把值传进去,相当于买了两个存钱罐,先不存钱,等我想存的时候我再把钱一张一张“喂”进去。
#Feed
#创建占位符
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
output = tf.multiply(input1,input2) with tf.Session() as sess:
#feed的数据以字典的形式传入
print (sess.run(output,feed_dict={input1:[7.], input2:[8.]}))

Tensorflow学习教程------Fetch and Feed的更多相关文章
- tensorflow中的Fetch、Feed(02-3)
import tensorflow as tf #Fetch概念 在session中同时运行多个op input1=tf.constant(3.0) #constant()是常量不用进行init初始化 ...
- Tensorflow学习教程------过拟合
Tensorflow学习教程------过拟合 回归:过拟合情况 / 分类过拟合 防止过拟合的方法有三种: 1 增加数据集 2 添加正则项 3 Dropout,意思就是训练的时候隐层神经元每次随机 ...
- Tensorflow学习教程------代价函数
Tensorflow学习教程------代价函数 二次代价函数(quadratic cost): 其中,C表示代价函数,x表示样本,y表示实际值,a表示输出值,n表示样本的总数.为简单起见,使用一 ...
- Tensorflow学习教程------读取数据、建立网络、训练模型,小巧而完整的代码示例
紧接上篇Tensorflow学习教程------tfrecords数据格式生成与读取,本篇将数据读取.建立网络以及模型训练整理成一个小样例,完整代码如下. #coding:utf-8 import t ...
- tensorflow 学习教程
tensorflow 学习手册 tensorflow 学习手册1:https://cloud.tencent.com/developer/section/1475687 tensorflow 学习手册 ...
- Tensorflow学习教程------创建图启动图
Tensorflow作为目前最热门的机器学习框架之一,受到了工业界和学界的热门追捧.以下几章教程将记录本人学习tensorflow的一些过程. 在tensorflow这个框架里,可以讲是若数据类型,也 ...
- Tensorflow学习教程------非线性回归
自己搭建神经网络求解非线性回归系数 代码 #coding:utf-8 import tensorflow as tf import numpy as np import matplotlib.pypl ...
- Tensorflow学习教程------利用卷积神经网络对mnist数据集进行分类_利用训练好的模型进行分类
#coding:utf-8 import tensorflow as tf from PIL import Image,ImageFilter from tensorflow.examples.tut ...
- Tensorflow学习教程------lenet多标签分类
本文在上篇的基础上利用lenet进行多标签分类.五个分类标准,每个标准分两类.实际来说,本文所介绍的多标签分类属于多任务学习中的联合训练,具体代码如下. #coding:utf-8 import te ...
随机推荐
- Ethernet IP TCP UDP 协议头部格式
The Ethernet header structure is shown in the illustration below: 以太网头部14 bytes Destination Source L ...
- docker 为镜像添加ssh服务-使用Dockerfile 创建
首先,基于要添加内容的镜像ubuntu:18.04运行一个容器, 在宿主机(下面步骤是在容器中创建的,应该在宿主机创建进行以下步骤) 一.创建一个工作目录 二.创建Dockerfile 和脚本run. ...
- NFC性价比高频读卡器首选方案:FM17550
FM17550具有低电压.低功耗.驱动能力强.多接口支持.多协议支持等特点.适用于低功耗.低电压.低成本要求的非接触读写器应用,及NFC协议兼容的NFC设备. FM17550是一款高度集成的工作在13 ...
- CSAPP读书笔记--第八章 异常控制流
第八章 异常控制流 2017-11-14 概述 控制转移序列叫做控制流.目前为止,我们学过两种改变控制流的方式: 1)跳转和分支: 2)调用和返回. 但是上面的方法只能控制程序本身,发生以下系统状态的 ...
- thinkphp5+python.apscheduler实现计划任务
1.thinkphp5配置自定义命令行 /application/console/command namespace app\console\command; use think\console\Co ...
- 7.5 Varnish VCL的变量和应用片段
- Win10下数据增强及标注工具安装
Win10下数据增强及标注工具安装 一. 数据增强利器—Augmentor 1.安装 只需在控制台输入:pip install Augmentor 2.简介 Augmentor是用于图像增强的软件 ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-move
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...
- TBLASTN
TBLASTN search translated nucleotide databases using a protein query
- 云时代架构阅读笔记七——Java多线程中如何使用synchronized关键字
关于线程的同步,可以使用synchronized关键字,或者是使用JDK 5中提供的java.util.concurrent.lock包中的Lock对象.本文探讨synchronized关键字. sy ...