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?的更多相关文章

  1. Tensorflow基本语法

    一.tf.Variables() import tensorflow as tf Weights = tf.Variable(tf.random_uniform([1], -1.0, 1.0)) se ...

  2. Tensorflow学习笔记2019.01.03

    tensorflow学习笔记: 3.2 Tensorflow中定义数据流图 张量知识矩阵的一个超集. 超集:如果一个集合S2中的每一个元素都在集合S1中,且集合S1中可能包含S2中没有的元素,则集合S ...

  3. TensorFlow入门(一)

    目录 TensorFlow简介 TensorFlow基本概念 Using TensorFlow Optimization & Linear Regression & Logistic ...

  4. TensorFlow 2.0 新特性

    安装 TensorFlow 2.0 Alpha 本文仅仅介绍 Windows 的安装方式: pip install tensorflow==2.0.0-alpha0 # cpu 版本 pip inst ...

  5. [Tensorflow] Cookbook - Object Classification based on CIFAR-10

    Convolutional Neural Networks (CNNs) are responsible for the major breakthroughs in image recognitio ...

  6. Effective Tensorflow[转]

    Effective TensorFlow Table of Contents TensorFlow Basics Understanding static and dynamic shapes Sco ...

  7. Tensorflow运行程序报错 FailedPreconditionError

    1 FailedPreconditionError错误现象 在运行tensorflow时出现报错,报错语句如下: FailedPreconditionError (see above for trac ...

  8. 53、tensorflow基本操作

    import tensorflow as tf import numpy as np x_data = np.float32(np.random.rand(2,100)) print(x_data) ...

  9. DeepLearning常用库简要介绍与对比

    网上近日流传一张DL相关库在Github上的受关注度对比(数据应该是2016/03/15左右统计的): 其中tensorflow,caffe,keras和Theano排名比较靠前. 今日组会报告上tj ...

随机推荐

  1. Win 10环境下6sV2.1模型编译心得

    最新版本6sV2.1模型是通过FORTRAN95编写的,2017年11月代码编写完成,2018年11月发布在模型官网上.通常我们在使用过程中都是调用模型的.exe可执行文件,而下载下来的是FORTRA ...

  2. pip3 install pyinstaller 报错了的处理方法

    http://www.pyinstaller.org/downloads.html 下载压缩包 解压到本地后,在目录处cmd 执行命令 python setup.py install 然后执行pip ...

  3. 第一次打开PyCharm的基本操作(附图)

    第一次打开PyCharm可能需要修改一些个性化和了解一些基本操作,有助于接下来的学习过程.(后续可能会更新) 我的版本是64位的1.3 1.换界面皮肤 默认黑色的,不喜欢黑色皮肤可以换成白色的 Fil ...

  4. Mathtype 问题汇总(3)

    1. 调整行间距 2. 调整字号 在 MathType 中,选择「大小 > 定义」将对话框中「完整」所对应的值改为和文字大小匹配的pt(磅值),这样便可以解决在文字编写的 Word 文档中某一行 ...

  5. homestead的创建和使用

    1.下载vistualbox和vagrant并安装 2.安装了git的话就在想设置的目录或者文件夹下用git命令执行vagrant box add laravel/homestead,或者用cmd命令 ...

  6. MAC自带Apache配置python3

    进入终端 sudo apachectl start 直接访问localhost 解决Mac下apache 403的问题 网上查资料发现是因为Mac版本升级导致了apache策略发生变更了,所以我们修改 ...

  7. ndarray笔记续

    数组的索引与切片 多维数组的索引 import numpy as np arr=np.arange(1,25).reshape(2,3,4) arr # 输出 array([[[ 1, 2, 3, 4 ...

  8. Redis键的序列化和反序列化

    序列化 命令名称:DUMP 语法:DUMP key 功能:序列化给定key,并返回被序列化的值.序列化的值不包括任何生存时间信息. 返回值:如果key不存在,那么返回nil.否则返回序列化之后的值 反 ...

  9. Spring Boot 默认首页

    //继承 WebMvcConfigurerAdapter @Override public void addViewControllers(ViewControllerRegistry registr ...

  10. 获取类的描述信息 DescriptionAttribute

    static void Main(string[] args) { var attrs = typeof(TestClass).GetCustomAttributes(typeof(System.Co ...