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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Tensorflow入门__实例:图计算

發(fā)布時間:2024/4/18 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Tensorflow入门__实例:图计算 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
import tensorflow.compat.v1 as tf #tf.compat.v1.get_default_graph#定義方程的參數(shù)為常量 a = tf.constant(5.0) b = tf.constant(4.5) c = tf.constant(3.0)#定義x為變量 默認(rèn)值為0 x = tf.Variable(0., name = 'x')#定義y為輸出 它是a、b、c和x上的操作 y = (a * x**2) + (b * x) + cfrom IPython.display import clear_output, Image, display, HTML import numpy as np def strip_consts(graph_def, max_const_size=32):"""去掉graph_def中的大數(shù)值"""strip_def = tf.GraphDef()for n0 in graph_def.node:n = strip_def.node.add() n.MergeFrom(n0)if n.op == 'Const':tensor = n.attr['value'].tensorsize = len(tensor.tensor_content)if size > max_const_size:tensor.tensor_content = "<stripped %d bytes>"%sizereturn strip_defdef show_graph(graph_def, max_const_size=32):"""可視化TensorFlow graph."""if hasattr(graph_def, 'as_graph_def'):graph_def = graph_def.as_graph_def()strip_def = strip_consts(graph_def, max_const_size=max_const_size)code = """<script>function load() {{document.getElementById("{id}").pbtxt = {data};}}</script><link rel="import" href="https://tensorboard.appspot.com/tf-graph-basic.build.html" οnlοad=load()><div style="height:600px"><tf-graph-basic id="{id}"></tf-graph-basic></div>""".format(data=repr(str(strip_def)), id='graph'+str(np.random.rand()))iframe = """<iframe seamless style="width:1200px;height:620px;border:0" srcdoc="{}"></iframe>""".format(code.replace('"', '&quot;'))display(HTML(iframe))show_graph(tf.get_default_graph().as_graph_def())

總結(jié)

以上是生活随笔為你收集整理的Tensorflow入门__实例:图计算的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。