import tensorflow as tf

with tf.variable_scope("foo"):
v = tf.get_variable("v", [1], initializer=tf.constant_initializer(1.0)) #with tf.variable_scope("foo"):
# v = tf.get_variable("v", [1]) with tf.variable_scope("foo", reuse=True):
v1 = tf.get_variable("v", [1])
print(v == v1) #with tf.variable_scope("bar", reuse=True):
# v = tf.get_variable("v", [1])

with tf.variable_scope("root"):
print(tf.get_variable_scope().reuse) with tf.variable_scope("foo", reuse=True):
print(tf.get_variable_scope().reuse) with tf.variable_scope("bar"):
print(tf.get_variable_scope().reuse) print(tf.get_variable_scope().reuse)

v1 = tf.get_variable("v", [1])
print(v1.name) with tf.variable_scope("foo",reuse=True):
v2 = tf.get_variable("v", [1])
print(v2.name) with tf.variable_scope("foo"):
with tf.variable_scope("bar"):
v3 = tf.get_variable("v", [1])
print(v3.name) v4 = tf.get_variable("v1", [1])
print(v4.name)

with tf.variable_scope("",reuse=True):
v5 = tf.get_variable("foo/bar/v", [1])
print(v5 == v3)
v6 = tf.get_variable("v1", [1])
print(v6 == v4)

吴裕雄 python 神经网络——TensorFlow 变量管理的更多相关文章

  1. 吴裕雄 python 神经网络——TensorFlow实现搭建基础神经网络

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt def add_layer(inputs, in_ ...

  2. 吴裕雄 python 神经网络——TensorFlow 使用卷积神经网络训练和预测MNIST手写数据集

    import tensorflow as tf import numpy as np from tensorflow.examples.tutorials.mnist import input_dat ...

  3. 吴裕雄 python 神经网络TensorFlow实现LeNet模型处理手写数字识别MNIST数据集

    import tensorflow as tf tf.reset_default_graph() # 配置神经网络的参数 INPUT_NODE = 784 OUTPUT_NODE = 10 IMAGE ...

  4. 吴裕雄 python 神经网络——TensorFlow 数据集高层操作

    import tempfile import tensorflow as tf train_files = tf.train.match_filenames_once("E:\\output ...

  5. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(4)

    # -*- coding: utf-8 -*- import glob import os.path import numpy as np import tensorflow as tf from t ...

  6. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(3)

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

  7. 吴裕雄 python 神经网络——TensorFlow 花瓣分类与迁移学习(2)

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

  8. 吴裕雄 python 神经网络——TensorFlow 花瓣识别2

    import glob import os.path import numpy as np import tensorflow as tf from tensorflow.python.platfor ...

  9. 吴裕雄 python 神经网络——TensorFlow 三层简单神经网络的前向传播算法

    import tensorflow as tf w1= tf.Variable(tf.random_normal([2, 3], stddev=1, seed=1)) w2= tf.Variable( ...

随机推荐

  1. 使用VS2017开发安卓app(2)新建项目

    安装完成后,在c#下找到Android,选择Android应用(Xamarin),修改项目名称和路径,新建第一个安卓项目! 点击确定后会出现 这里我们选择空白应用和Android 7.1. 创建新项目 ...

  2. django入门(一)

    小白一枚,老是感觉自己学了点什么东西马上就忘了,所以打算写点下来,以后可以看看,也希望能给以后点进来的人有一些帮助 本文是django的入门,现在在学,有错误之处还希望能包涵和指出,谢谢! 首先先下载 ...

  3. leetcode78.子集➕90.子集2

    78子集 dfs dfs1: 和全排列的区别就是对于当前考察的索引i,全排列如果不取i,之后还要取i,所以需要一个visited数组用来记录.对于子集问题如果不取i,之后也不必再取i. 单纯递归回溯 ...

  4. Git - 05. git log & git show

    1. 概述 有了提交, 就必须有日志 日志用处很多, 这里我就不多说了 2. 项目日志 概述 查看当前分支的 提交记录 命令 普通查看 命令 > git log 显示 commit id 包括 ...

  5. 每天进步一点点------如何实现Sobel Edge Detector? (Image Processing) (C/C++)

    使用C與C++/CLI實現Sobel Edge Detector. http://www.cnblogs.com/oomusou/archive/2008/07/23/sobel_edge_detec ...

  6. maven设置指定jdk版本

    今天心血来潮准备折腾一下jeecg,去下载了一个maven版本的项目,既然下载了maven版的,当然就要配置好maven环境了. 因为之前简单学习过maven,当时使用的版本是3.3.9的,但是今天在 ...

  7. Java 前加加和后加加 总结

    public class Test { public static void main(String[] args) { int age = 6; //先自加,再使用(age先自加1,然后再打印age ...

  8. [转载]PHP开发环境 AppServ 2.5.10 安装及修改

    [转载]PHP开发环境 AppServ 2.5.10 安装及修改   原文地址:PHP开发环境 AppServ 2.5.10 安装及修改 appserv下载地址:http://www.appservn ...

  9. 树莓派下编译并使用miracl密码库

    参考:Linux下编译并使用miracl密码库 MIRACL用户手册:https://wenku.baidu.com/view/d542f2ed0975f46527d3e1dc.html 具体过程. ...

  10. ubuntu安装与设置

    为学习Linux,在虚拟机中安装类ubuntu18.04,刚装完系统时间是不对的,系统中也没有gcc,g++. 关于安装软件无非就是: sudo apt-get install gcc sudo ap ...