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 ...
随机推荐
- react做的简单的购物车
###第一步 :首先电脑上已经安装react的脚手架 cnpm install create-react-app -g ###第二步 :创建项目 creact-react-app 项目 ...
- ML.Net Model Builder
ML.Net Model Builder ML.NET技术研究系列1-入门篇 近期团队在研究机器学习,希望通过机器学习实现补丁发布评估,系统异常检测.业务场景归纳一下: 收集整理数据(发布相关的异 ...
- 基于Jquery ui 可复用的酒店 web页面选择入住日期插件
效果图: 代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" ...
- javascript判断碰撞检测
javascript判断碰撞检测 点与矩形的碰撞检测 <pre> /** * * @param x1 点 * @param y1 点 * @param x2 矩形view x * @par ...
- 第三坑:jar包编译版本
这个是之前往was上发应用的时候踩的一个坑,当时我们知道was的jdk版本是1.6,然后我们是用1.7的jdk,编译版本选的是1.6,然后放上去不对,我们以为是编译的问题,然后又下载了1.6的jdk, ...
- IP地址 子网掩码 网络地址 主机地址 广播地址
1.一定要明白各自的概念分别表示什么 IP地址:IP地址是用来识别网络上的设备,因此,IP地址是由网络地址与主机地址两部分所组成. 子网掩码:子网掩码不能单独存在,它必须结合IP地址一起使用.子网掩码 ...
- shell习题第22题:
[题目要求] 加入A服务器可直接ssh到B,不用输入密码.A和B都有一个目录是/data/web/这下有很多文件,我们不知道这下面有多少层目录,但是之前的目录结构和文件是一模一样的.但是现在不确定是否 ...
- MySQL 5.7 多源复制实践
多源复制使用场景 数据分析部门会需要各个业务部门的部分数据做数据分析,这个时候就可以用到多源复制把各个主数据库的数据复制到统一的数据库中. 在从服务器进行数据汇总,如果我们的主服务器进行了分库分表的操 ...
- IDEA GIT 忽略文件 最佳方式
前言 转载一篇博客,简单,实用. 原文地址:intellij idea 忽略文件不提交 ps:下面均为转载博客的内容: 在intellij中忽略提交文件,分两种情况, 文件没有纳入版本管理 第一种,文 ...
- Unity中的Character Controller
Unity中默认提供了一个Character Controller的组件用于实现角色控制,一个3D的游戏物体,可以直接添加.Character Controller会自动模拟出Capsule Coll ...