当前位置: 首页>>代码示例>>Python>>正文


Python model_analyzer.print_model_analysis方法代码示例

本文整理汇总了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) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:16,代码来源:model_test.py

示例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 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:7,代码来源:train.py

示例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"])) 
开发者ID:pandegroup,项目名称:reaction_prediction_seq2seq,代码行数:30,代码来源:profile.py


注:本文中的tensorflow.contrib.tfprof.model_analyzer.print_model_analysis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。