-
大小: 20KB文件類型: .rar金幣: 2下載: 0 次發布日期: 2021-06-15
- 語言: 其他
- 標簽: tensorflow??直接量化??
資源簡介
tensorflow demo中以前版本支持的量化方式,在后續版本中被移除了??捎糜趯W習如何量化,有一定價值。注意,之前該文件位于tensorflow-master/tensorflow/tools/文件夾下。
如果沒有積分 可以私信我 我單獨發給你

代碼片段和文件信息
#?Copyright?2015?The?TensorFlow?Authors.?All?Rights?Reserved.
#
#?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
#?you?may?not?use?this?file?except?in?compliance?with?the?License.
#?You?may?obtain?a?copy?of?the?License?at
#
#?????http://www.apache.org/licenses/LICENSE-2.0
#
#?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
#?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
#?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
#?See?the?License?for?the?specific?language?governing?permissions?and
#?limitations?under?the?License.
#?==============================================================================
“““Converts?a?GraphDef?file?into?a?DOT?format?suitable?for?visualization.
This?script?takes?a?GraphDef?representing?a?network?and?produces?a?DOT?file
that?can?then?be?visualized?by?GraphViz?tools?like?dot?and?xdot.
“““
from?__future__?import?absolute_import
from?__future__?import?division
from?__future__?import?print_function
import?re
from?google.protobuf?import?text_format
from?tensorflow.core.framework?import?graph_pb2
from?tensorflow.python.platform?import?app
from?tensorflow.python.platform?import?flags
from?tensorflow.python.platform?import?gfile
FLAGS?=?flags.FLAGS
flags.DEFINE_string(“graph“?““?“““TensorFlow?‘GraphDef‘?file?to?load.“““)
flags.DEFINE_bool(“input_binary“?True
??????????????????“““Whether?the?input?files?are?in?binary?format.“““)
flags.DEFINE_string(“dot_output“?““?“““Where?to?write?the?DOT?output.“““)
def?main(unused_args):
??if?not?gfile.Exists(FLAGS.graph):
????print(“Input?graph?file?‘“?+?FLAGS.graph?+?“‘?does?not?exist!“)
????return?-1
??graph?=?graph_pb2.GraphDef()
??with?open(FLAGS.graph?“r“)?as?f:
????if?FLAGS.input_binary:
??????graph.ParseFromString(f.read())
????else:
??????text_format.Merge(f.read()?graph)
??with?open(FLAGS.dot_output?“wb“)?as?f:
????print(“digraph?graphname?{“?file=f)
????for?node?in?graph.node:
??????output_name?=?node.name
??????print(“??\““?+?output_name?+?“\“?[label=\““?+?node.op?+?“\“];“?file=f)
??????for?input_full_name?in?node.input:
????????parts?=?input_full_name.split(“:“)
????????input_name?=?re.sub(r“^\^“?““?parts[0])
????????print(“??\““?+?input_name?+?“\“?->?\““?+?output_name?+?“\“;“?file=f)
????print(“}“?file=f)
??print(“Created?DOT?file?‘“?+?FLAGS.dot_output?+?“‘.“)
if?__name__?==?“__main__“:
??app.run()
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2268??2018-09-14?11:39??quantization\BUILD
?????文件???????2418??2018-09-14?11:39??quantization\graph_to_dot.py
?????文件??????57233??2018-09-14?11:39??quantization\quantize_graph.py
?????文件??????42452??2018-09-14?11:39??quantization\quantize_graph_test.py
?????目錄??????????0??2018-12-11?17:17??quantization
-----------?---------??----------?-----??----
???????????????104371????????????????????5
- 上一篇:maven學習資料
- 下一篇:lcd多級菜單的實現
評論
共有 條評論