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


Python model_deploy.deploy方法代码示例

本文整理汇总了Python中deployment.model_deploy.deploy方法的典型用法代码示例。如果您正苦于以下问题:Python model_deploy.deploy方法的具体用法?Python model_deploy.deploy怎么用?Python model_deploy.deploy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在deployment.model_deploy的用法示例。


在下文中一共展示了model_deploy.deploy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testNoSummariesOnGPU

# 需要导入模块: from deployment import model_deploy [as 别名]
# 或者: from deployment.model_deploy import deploy [as 别名]
def testNoSummariesOnGPU(self):
    with tf.Graph().as_default():
      deploy_config = model_deploy.DeploymentConfig(num_clones=2)

      # clone function creates a fully_connected layer with a regularizer loss.
      def ModelFn():
        inputs = tf.constant(1.0, shape=(10, 20), dtype=tf.float32)
        reg = tf.contrib.layers.l2_regularizer(0.001)
        tf.contrib.layers.fully_connected(inputs, 30, weights_regularizer=reg)

      model = model_deploy.deploy(
          deploy_config, ModelFn,
          optimizer=tf.train.GradientDescentOptimizer(1.0))
      # The model summary op should have a few summary inputs and all of them
      # should be on the CPU.
      self.assertTrue(model.summary_op.op.inputs)
      for inp in  model.summary_op.op.inputs:
        self.assertEqual('/device:CPU:0', inp.device) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:20,代码来源:model_deploy_test.py

示例2: testNoSummariesOnGPUForEvals

# 需要导入模块: from deployment import model_deploy [as 别名]
# 或者: from deployment.model_deploy import deploy [as 别名]
def testNoSummariesOnGPUForEvals(self):
    with tf.Graph().as_default():
      deploy_config = model_deploy.DeploymentConfig(num_clones=2)

      # clone function creates a fully_connected layer with a regularizer loss.
      def ModelFn():
        inputs = tf.constant(1.0, shape=(10, 20), dtype=tf.float32)
        reg = tf.contrib.layers.l2_regularizer(0.001)
        tf.contrib.layers.fully_connected(inputs, 30, weights_regularizer=reg)

      # No optimizer here, it's an eval.
      model = model_deploy.deploy(deploy_config, ModelFn)
      # The model summary op should have a few summary inputs and all of them
      # should be on the CPU.
      self.assertTrue(model.summary_op.op.inputs)
      for inp in  model.summary_op.op.inputs:
        self.assertEqual('/device:CPU:0', inp.device) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:model_deploy_test.py


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