欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

tensorflow 打印內(nèi)存中的變量方法

 更新時間:2018年07月30日 09:45:42   作者:JNingWei  
今天小編就為大家分享一篇tensorflow 打印內(nèi)存中的變量方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

法一:

循環(huán)打印

模板

for (x, y) in zip(tf.global_variables(), sess.run(tf.global_variables())):
 print '\n', x, y

實例

# coding=utf-8

import tensorflow as tf


def func(in_put, layer_name, is_training=True):
 with tf.variable_scope(layer_name, reuse=tf.AUTO_REUSE):
  bn = tf.contrib.layers.batch_norm(inputs=in_put,
           decay=0.9,
           is_training=is_training,
           updates_collections=None)
 return bn

def main():

 with tf.Graph().as_default():
  # input_x
  input_x = tf.placeholder(dtype=tf.float32, shape=[1, 4, 4, 1])
  import numpy as np
  i_p = np.random.uniform(low=0, high=255, size=[1, 4, 4, 1])
  # outputs
  output = func(input_x, 'my', is_training=True)
  with tf.Session() as sess:
   sess.run(tf.global_variables_initializer())
   t = sess.run(output, feed_dict={input_x:i_p})

   # 法一: 循環(huán)打印
   for (x, y) in zip(tf.global_variables(), sess.run(tf.global_variables())):
    print '\n', x, y

if __name__ == "__main__":
 main()
2017-09-29 10:10:22.714213: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1052] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)

<tf.Variable 'my/BatchNorm/beta:0' shape=(1,) dtype=float32_ref> [ 0.]

<tf.Variable 'my/BatchNorm/moving_mean:0' shape=(1,) dtype=float32_ref> [ 13.46412563]

<tf.Variable 'my/BatchNorm/moving_variance:0' shape=(1,) dtype=float32_ref> [ 452.62246704]

Process finished with exit code 0

法二:

指定變量名打印

模板

print 'my/BatchNorm/beta:0', (sess.run('my/BatchNorm/beta:0'))

實例

# coding=utf-8

import tensorflow as tf


def func(in_put, layer_name, is_training=True):
 with tf.variable_scope(layer_name, reuse=tf.AUTO_REUSE):
  bn = tf.contrib.layers.batch_norm(inputs=in_put,
           decay=0.9,
           is_training=is_training,
           updates_collections=None)
 return bn

def main():

 with tf.Graph().as_default():
  # input_x
  input_x = tf.placeholder(dtype=tf.float32, shape=[1, 4, 4, 1])
  import numpy as np
  i_p = np.random.uniform(low=0, high=255, size=[1, 4, 4, 1])
  # outputs
  output = func(input_x, 'my', is_training=True)
  with tf.Session() as sess:
   sess.run(tf.global_variables_initializer())
   t = sess.run(output, feed_dict={input_x:i_p})

   # 法二: 指定變量名打印
   print 'my/BatchNorm/beta:0', (sess.run('my/BatchNorm/beta:0'))
   print 'my/BatchNorm/moving_mean:0', (sess.run('my/BatchNorm/moving_mean:0'))
   print 'my/BatchNorm/moving_variance:0', (sess.run('my/BatchNorm/moving_variance:0'))

if __name__ == "__main__":
 main()
2017-09-29 10:12:41.374055: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1052] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)

my/BatchNorm/beta:0 [ 0.]
my/BatchNorm/moving_mean:0 [ 8.08649635]
my/BatchNorm/moving_variance:0 [ 368.03442383]

Process finished with exit code 0

以上這篇tensorflow 打印內(nèi)存中的變量方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • python基于tkinter制作下班倒計時工具

    python基于tkinter制作下班倒計時工具

    這篇文章主要介紹了python基于tkinter制作倒計時工具的方法,幫助大家更好的理解和學(xué)習(xí)使用python,感興趣的朋友可以了解下
    2021-04-04
  • 一篇文章徹底搞懂Python切片操作

    一篇文章徹底搞懂Python切片操作

    利用python解決問題的過程中,經(jīng)常會遇到從某個對象中抽取部分值的情況,"切片"操作正是專門用于實現(xiàn)這一目標的有力武器,下面這篇文章主要給大家介紹了關(guān)于Python切片操作的相關(guān)資料,需要的朋友可以參考下
    2022-06-06
  • 在Mac下使用python實現(xiàn)簡單的目錄樹展示方法

    在Mac下使用python實現(xiàn)簡單的目錄樹展示方法

    今天小編就為大家分享一篇在Mac下使用python實現(xiàn)簡單的目錄樹展示方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-11-11
  • 解決pyinstaller打包exe文件出現(xiàn)命令窗口一閃而過的問題

    解決pyinstaller打包exe文件出現(xiàn)命令窗口一閃而過的問題

    今天小編就為大家分享一篇解決pyinstaller打包exe文件出現(xiàn)命令窗口一閃而過的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-10-10
  • 解決pycharm每次打開項目都需要配置解釋器和安裝庫問題

    解決pycharm每次打開項目都需要配置解釋器和安裝庫問題

    最近在使用pycharm開發(fā)新項目的時候,每次打開新的工程都顯示沒有解釋器,要不加了解釋器就是代碼一堆沒有紅色錯誤提示沒有模塊問題,很多朋友都遇到過這種情況,現(xiàn)小編把解決方法分享到腳本之家平臺,需要的朋友一起看看吧
    2020-02-02
  • python 項目目錄結(jié)構(gòu)設(shè)置

    python 項目目錄結(jié)構(gòu)設(shè)置

    JAVA有標準的maven目錄結(jié)構(gòu),golang也有建議的目錄結(jié)構(gòu),那么我想python是不是也有一個比較好的目錄結(jié)構(gòu)組織方式呢
    2020-02-02
  • 簡單介紹django提供的加密算法

    簡單介紹django提供的加密算法

    在本篇文章里小編給大家分享的是關(guān)于django提供的加密算法的相關(guān)知識點,有需要的朋友們學(xué)習(xí)下。
    2019-12-12
  • python實現(xiàn)月食效果實例代碼

    python實現(xiàn)月食效果實例代碼

    在本文里小編給大家整理了關(guān)于python實現(xiàn)月食效果的相關(guān)實例內(nèi)容以及對應(yīng)代碼,有興趣的朋友們學(xué)習(xí)下。
    2019-06-06
  • 關(guān)于python3.7安裝matplotlib始終無法成功的問題的解決

    關(guān)于python3.7安裝matplotlib始終無法成功的問題的解決

    這篇文章主要介紹了關(guān)于python3.7安裝matplotlib始終無法成功的問題的解決,文中通過圖文介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • Python實現(xiàn)構(gòu)建一個儀表板的示例代碼

    Python實現(xiàn)構(gòu)建一個儀表板的示例代碼

    這篇文章主要為大家詳細介紹了Python如何實現(xiàn)構(gòu)建一個儀表板,文中的示例代碼講解詳細,具有一定的參考價值,感興趣的小伙伴可以了解一下
    2023-03-03

最新評論