Why do we name variables in Tensorflow?
Reference:Stack Overflow。
The name parameter is optional (you can create variables and constants with or without it), and the variable you use in your program does not depend on it. Names can be helpful in a couple of places:
When you want to save or restore your variables (you can save them to a binary file after the computation). From docs:
By default, it uses the value of the Variable.name property for each variable
matrix_1 = tf.Variable([[1, 2], [2, 3]], name="v1")
matrix_2 = tf.Variable([[3, 4], [5, 6]], name="v2")
init = tf.initialize_all_variables()
saver = tf.train.Saver()
sess = tf.Session()
sess.run(init)
save_path = saver.save(sess, "/model.ckpt")
sess.close()
Nonetheless you have variables matrix_1, matrix_2 they are saves as v1, v2 in the file.
Also names are used in TensorBoard to nicely show names of edges. You can even group them by using the same scope:
import tensorflow as tf
with tf.name_scope('hidden') as scope:
a = tf.constant(5, name='alpha')
W = tf.Variable(tf.random_uniform([1, 2], -1.0, 1.0), name='weights')
b = tf.Variable(tf.zeros([1]), name='biases')
How does TensorFlow name tensors?
In TensorFlow,what's the meaning of “:0” in a Variable's name?
It has to do with representation of tensors in underlying API. A tensor is a value associated with output of some op. In case of variables, there's a Variable op with one output. An op can have more than one output, so those tensors get referenced to as <op>:0, <op>:1 etc. For instance if you use tf.nn.top_k, there are two values created by this op, so you may see TopKV2:0 and TopKV2:1
a,b=tf.nn.top_k([1], 1)
print a.name # => 'TopKV2:0'
print b.name # => 'TopKV2:1'
How to understand the term `tensor` in TensorFlow?
Why do we name variables in Tensorflow?的更多相关文章
- Tensorflow基本语法
一.tf.Variables() import tensorflow as tf Weights = tf.Variable(tf.random_uniform([1], -1.0, 1.0)) se ...
- Tensorflow学习笔记2019.01.03
tensorflow学习笔记: 3.2 Tensorflow中定义数据流图 张量知识矩阵的一个超集. 超集:如果一个集合S2中的每一个元素都在集合S1中,且集合S1中可能包含S2中没有的元素,则集合S ...
- TensorFlow入门(一)
目录 TensorFlow简介 TensorFlow基本概念 Using TensorFlow Optimization & Linear Regression & Logistic ...
- TensorFlow 2.0 新特性
安装 TensorFlow 2.0 Alpha 本文仅仅介绍 Windows 的安装方式: pip install tensorflow==2.0.0-alpha0 # cpu 版本 pip inst ...
- [Tensorflow] Cookbook - Object Classification based on CIFAR-10
Convolutional Neural Networks (CNNs) are responsible for the major breakthroughs in image recognitio ...
- Effective Tensorflow[转]
Effective TensorFlow Table of Contents TensorFlow Basics Understanding static and dynamic shapes Sco ...
- Tensorflow运行程序报错 FailedPreconditionError
1 FailedPreconditionError错误现象 在运行tensorflow时出现报错,报错语句如下: FailedPreconditionError (see above for trac ...
- 53、tensorflow基本操作
import tensorflow as tf import numpy as np x_data = np.float32(np.random.rand(2,100)) print(x_data) ...
- DeepLearning常用库简要介绍与对比
网上近日流传一张DL相关库在Github上的受关注度对比(数据应该是2016/03/15左右统计的): 其中tensorflow,caffe,keras和Theano排名比较靠前. 今日组会报告上tj ...
随机推荐
- ELK7.4.2安装教程
ELK简介 "ELK"是三个开源项目的首字母缩写,这三个项目分别是:Elasticsearch.Logstash 和 Kibana.Elasticsearch 是一个搜索和分析引擎 ...
- subplot()一个窗口画多个图
import matplotlib.pyplot as plt plt.subplot(m,n,p) m,n表示一个窗口上显示m行n列 p表示正在处理第p个区域的部分(区域编号从左到右,从上到下) f ...
- 微信公众号对接JS-SDK接口 调用微信内置地图
微信js-sdk开发文档:https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html 1.页面配置 引用微信js- ...
- 什么是H5?
总听到很多人说H5,现在H5很火,到底H5是什么,以下发表个人对H5的理解. HTML5 将成为 HTML.XHTML 以及 HTML DOM 的新标准. HTML 的上一个版本诞生于 1999 年. ...
- websocket抓包
https://www.cnblogs.com/xiaoniuzai/p/7588739.html http://blog.sina.com.cn/s/blog_12df1b9e60102vyeq.h ...
- C#中输入法全角转换半角
一般情况下,我们都是使用英文半角的来进行编程,包括输入框和密码框的设定一般也是英文半角,但往往有些人使用全角输入,登陆不进去还以为你系统错误,现整理了几种全角切换半角和设定输入法的几种方法. 方法一: ...
- 《Mysql 事务 - 隔离》
一:事务概念 - ACID(Atomicity.Consistency.Isolation.Durability,即原子性.一致性.隔离性.持久性) 二:事务产生的问题 - 多个事务同时执行的时候 ...
- wordpress 后台无法登录 网站内容缺失
昨天网站又突然不正常了,前两天都是好的.. 具体来说就是wp后台登录不进去,一直在登录页跳转,与此同时服务器上其他网站也有这个问题,而且有些网站的板块内容也缺失了, 所以首要就是要登录进后台看看是不是 ...
- 20191011-构建我们公司自己的自动化接口测试框架-Util的读取excel常用方法模块
包括获取excel的sheet名字,设定excel的sheet,读excel,写excel等常规操作. from openpyxl import Workbook from openpyxl impo ...
- 资源|《美团机器学习实践》PDF+思维导图
今天再给大家推荐一本由美团算法团队出版的<美团机器学习实践>,下载链接见文末. 美团算法团队由数百名优秀算法工程师组成,负责构建美团这个生活服务互联网大平台的"大脑", ...