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_1matrix_2 they are saves as v1v2 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. vue项目使用keep-alive的作用

    在vue项目中,难免会有列表页面或者搜索结果列表页面,点击某个结果之后,返回回来时,如果不对结果页面进行缓存,那么返回列表页面的时候会回到初始状态,但是我们想要的结果是返回时这个页面还是之前搜索的结果 ...

  2. 涨停复盘:5G概念持续活跃,军工股强势崛起

    午后银行股快速拉升,三大股指大幅拉升,沪指一度临近2800点,但未能持续随后沪指小幅下行,题材股表现强势,证券板块高开低走.截止收盘,沪指涨0.93%,创业板指涨1.51%. 盘面上,银行板块午后拉升 ...

  3. VLOOKUP函数 from Excel

    1.VLOOKUP函数是Excel中的一个纵向查找函数,它与LOOKUP函数和HLOOKUP函数属于一类函数,在工作中都有广泛应用,例如可以用来核对数据,多个表格之间快速导入数据等函数功能.功能是按列 ...

  4. AutoMapper扩展帮助类

    /// <summary> /// AutoMapper扩展帮助类 /// </summary> public static class AutoMapperExtension ...

  5. selenium + python 环境配置 (三)之启动chrome

    安装启动chromedriver的方法和ie类似 2.启动chrome 即selenium调用ChromeDriver打开Chrome浏览器 ①下载并解压,你会得到一个chromedriver.exe ...

  6. 如何使用Curator监听zookeeper事件变化

    掌握zookeeper事件监听机制,非常重要,可以说是跨入了进阶的门槛,只有掌握了如何监听某个节点或路径,我们才能在节点变化后,做一些我们想做的事,包括: 1,配置文件同步 2,主从切换 3,分布式队 ...

  7. Shuffle 机制

    1. 概述 Map 方法之后,Reduce 方法之前的数据处理过程称之为 Shuffle. 2. Partition 分区 需求:要求将统计结果按照条件输出到不同文件中(分区).比如:将统计结果按照手 ...

  8. ndarray笔记

    Numpy的介绍 1. Ndarray:N-dimensional array, N维数组 2. 一种由相同类型的元素组成的多维数组,元素数量是事先指定好的 例:建立Ndarray多维数组    nd ...

  9. Go学习路径--相关基础

    现在开始接触Go一段时间了,基本路径就是看基础学习材料,开始写项目,有问题找解决问题的方法.这里记录一下学习过程. go相关文章 Golang适合高并发场景的原因分析 go build 不同系统下的可 ...

  10. ELK 日志收集系统

    传统系统日志收集的问题 在传统项目中,如果在生产环境中,有多台不同的服务器集群,如果生产环境需要通过日志定位项目的Bug的话,需要在每台节点上使用传统的命令方式查询,这样效率非常底下. 通常,日志被分 ...