日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

吴裕雄 python 神经网络——TensorFlow 图、张量及会话

發布時間:2024/8/26 python 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 吴裕雄 python 神经网络——TensorFlow 图、张量及会话 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import tensorflow as tfg1 = tf.Graph() with g1.as_default():v = tf.get_variable("v", [1], initializer = tf.zeros_initializer()) # 設置初始值為0 g2 = tf.Graph() with g2.as_default():v = tf.get_variable("v", [1], initializer = tf.ones_initializer()) # 設置初始值為1 with tf.Session(graph = g1) as sess:tf.global_variables_initializer().run()with tf.variable_scope("", reuse=True):print(sess.run(tf.get_variable("v")))with tf.Session(graph = g2) as sess:tf.global_variables_initializer().run()with tf.variable_scope("", reuse=True):print(sess.run(tf.get_variable("v")))

import tensorflow as tfa = tf.constant([1.0, 2.0], name="a") b = tf.constant([2.0, 3.0], name="b") result = a + b print resultsess = tf.InteractiveSession () print(result.eval()) sess.close()

# 創建一個會話。 sess = tf.Session()# 使用會話得到之前計算的結果。 print(sess.run(result))# 關閉會話使得本次運行中使用到的資源可以被釋放。 sess.close()

with tf.Session() as sess:print(sess.run(result))

sess = tf.Session() with sess.as_default():print(result.eval())

sess = tf.Session()# 下面的兩個命令有相同的功能。 print(sess.run(result)) print(result.eval(session=sess))

sess = tf.InteractiveSession () print(result.eval()) sess.close()

config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True) sess1 = tf.InteractiveSession(config=config) sess2 = tf.Session(config=config)

?

轉載于:https://www.cnblogs.com/tszr/p/10872464.html

總結

以上是生活随笔為你收集整理的吴裕雄 python 神经网络——TensorFlow 图、张量及会话的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。