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 ...
随机推荐
- Java中遍历 Session 和 Request
转: session的遍历: java.util.Enumeration e = request.getSession().getAttributeNames(); while( e.hasMoreE ...
- hook框架frida添加至于安卓应用中
转载至于https://koz.io/using-frida-on-android-without-root/ Frida is a great toolkit by @oleavr, used to ...
- 017、MySQL取第4本季度开始和结束日期
#取第4本季度开始和结束日期 SELECT QUARTER ( adddate( dy, ) ) QTR, date_add( dy, INTERVAL MONTH ) Q_start, adddat ...
- leetcode1042 Flower Planting With No Adjacent
""" You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 t ...
- python -- 相对路径、绝对路径、以及路径的获取
1.定义 绝对路径:就是文件的真正存在的路径,是指从硬盘的根目录(盘符)开始,进行一级级目录指向文件. 相对路径:就是以当前文件为基准进行一级级目录指向被引用的资源文件. ../ 表示当前文件所在 ...
- maven集成SSM项目,Tomcat部署运行——SSM整合框架搭建(二)之问题
问题一.当放开controller中的方法,出现如下问题 ### Error querying database. Cause: org.springframework.jdbc.CannotGetJ ...
- doc转docx
# -*- coding: utf-8-*- import win32com from win32com.client import Dispatch w = win32com.client.Disp ...
- Vulkan SDK 之 DrawCube
Waiting for a Swapchain Buffer Beginning the Render Pass Bind the Pipeline Bind the Descriptor Sets ...
- 三、JavaScript之隐藏HTML元素
一.代码如下 二.点击前效果 三.点击后效果 <!DOCTYPE html> <html> <meta http-equiv="Content-Type&quo ...
- Docker部署Python应用程序
Docker部署Python应用程序 1. 单个py文件部署 生成Dockerfile 文件 插件用的豆瓣的镜像,,重置时间(容器的默认时间是UTC时间与宿主机的相差8小时). 文中需要三个插件(pe ...