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 ...
随机推荐
- npm的问题【解决】
1.解决npm下载慢的问题,使用该命令 npm install --registry=https://registry.npm.taobao.org 好处:比起cnpm官网解释的,这个更好,使用cnp ...
- linux下的进程间通信概述
管道(PIPE) FIFO(有名管道) XSI消息队列 XSI信号量 XSI共享内存 POSIX信号量 域套接字(Domain Socket) 信号(Signal) 互斥量(Mutex) 其中信号(s ...
- 中检测到有潜在危险的 Request.Form 值
经常会出现从客户端(xxx)中检测到有潜在危险的 Request.Form 值. 这个问题我们只用在web.config中添加一句代码即可 <system.web> <pages v ...
- java类加载全过程
引用:http://blog.csdn.net/haluoluo211/article/details/49908463 http://www.cnblogs.com/pengfeiliu/p/442 ...
- vue报错:Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
在.vue文件中引入了 element-ui 的 table 和 pagination 组件后,报错:Component template should contain exactly one roo ...
- VBA来实现已存在的数据库,取得所有表的结构
问题描述 用VBA来取出MySQL数据库中的所有表的结构后生成一个Excel的文档 首先创建MySQL的数据源,如何创建数据源在前章已经写过,之后把下面的信息填写上即可 在window7 64位系统上 ...
- C#中使用HttpClient来Post数据的内容HttpContent的各种格式
平时使用各种网络传输的时候基本上是以Json格式进行的, 所以对其他几种格式也是一知半解, 今天静下心对其好好梳理一番. 首先我借鉴了一篇文章(https://segmentfault.com/a/1 ...
- 数据结构 -- 链表(LinkedList)
链表是一种物理存储单元上非连续.非顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针链接次序实现的.链表由一系列结点(链表中每一个元素称为结点)组成,结点可以在运行时动态生成. 每个结点包括两个部分 ...
- JWT 身份认证优缺点分析以及常见问题解决方案
本文转载自:JWT 身份认证优缺点分析以及常见问题解决方案 Token 认证的优势 相比于 Session 认证的方式来说,使用 token 进行身份认证主要有下面三个优势: 1.无状态 token ...
- 20191011-构建我们公司自己的自动化接口测试框架-Action的request方法封装
Action模块 封装接口request方法,根据传入的参数调用不同的请求方法,因为项目特色,我们公司的接口都是get和post方法,所以仅仅封装了get和post方法: import request ...