本文整理汇总了Python中tensorflow.contrib.tfprof.model_analyzer.print_model_analysis方法的典型用法代码示例。如果您正苦于以下问题:Python model_analyzer.print_model_analysis方法的具体用法?Python model_analyzer.print_model_analysis怎么用?Python model_analyzer.print_model_analysis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.contrib.tfprof.model_analyzer
的用法示例。
在下文中一共展示了model_analyzer.print_model_analysis方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_model_size_less_then1_gb
# 需要导入模块: from tensorflow.contrib.tfprof import model_analyzer [as 别名]
# 或者: from tensorflow.contrib.tfprof.model_analyzer import print_model_analysis [as 别名]
def test_model_size_less_then1_gb(self):
# NOTE: Actual amount of memory occupied my TF during training will be at
# least 4X times bigger because of space need to store original weights,
# updates, gradients and variances. It also depends on the type of used
# optimizer.
ocr_model = self.create_model()
ocr_model.create_base(images=self.fake_images, labels_one_hot=None)
with self.test_session() as sess:
tfprof_root = model_analyzer.print_model_analysis(
sess.graph,
tfprof_options=model_analyzer.TRAINABLE_VARS_PARAMS_STAT_OPTIONS)
model_size_bytes = 4 * tfprof_root.total_parameters
self.assertLess(model_size_bytes, 1 * 2**30)
示例2: calculate_graph_metrics
# 需要导入模块: from tensorflow.contrib.tfprof import model_analyzer [as 别名]
# 或者: from tensorflow.contrib.tfprof.model_analyzer import print_model_analysis [as 别名]
def calculate_graph_metrics():
param_stats = model_analyzer.print_model_analysis(
tf.get_default_graph(),
tfprof_options=model_analyzer.TRAINABLE_VARS_PARAMS_STAT_OPTIONS)
return param_stats.total_parameters
示例3: main
# 需要导入模块: from tensorflow.contrib.tfprof import model_analyzer [as 别名]
# 或者: from tensorflow.contrib.tfprof.model_analyzer import print_model_analysis [as 别名]
def main(_argv):
"""Main functions. Runs all anaylses."""
# pylint: disable=W0212
tfprof_logger._merge_default_with_oplog = merge_default_with_oplog
FLAGS.model_dir = os.path.abspath(os.path.expanduser(FLAGS.model_dir))
output_dir = os.path.join(FLAGS.model_dir, "profile")
gfile.MakeDirs(output_dir)
run_meta, graph, op_log = load_metadata(FLAGS.model_dir)
param_arguments = [
param_analysis_options(output_dir),
micro_anaylsis_options(output_dir),
flops_analysis_options(output_dir),
device_analysis_options(output_dir),
]
for tfprof_cmd, params in param_arguments:
model_analyzer.print_model_analysis(
graph=graph,
run_meta=run_meta,
op_log=op_log,
tfprof_cmd=tfprof_cmd,
tfprof_options=params)
if params["dump_to_file"] != "":
print("Wrote {}".format(params["dump_to_file"]))