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


Python model.Model方法代码示例

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


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

示例1: main

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import Model [as 别名]
def main():
    """Main function"""
    args = parse_args()

    smiles_list = uc.read_smi_file(args.input_smiles_path)

    LOG.info("Building vocabulary")
    tokenizer = mv.SMILESTokenizer()
    vocabulary = mv.create_vocabulary(smiles_list, tokenizer=tokenizer)

    tokens = vocabulary.tokens()
    LOG.info("Vocabulary contains %d tokens: %s", len(tokens), tokens)
    network_params = {
        'num_layers': args.num_layers,
        'num_dimensions': args.layer_size,
        'embedding_layer_size': args.embedding_layer_size,
        'dropout': args.dropout,
        'vocabulary_size': len(vocabulary)
    }
    model = mm.Model(no_cuda=True, vocabulary=vocabulary, tokenizer=tokenizer,
                     network_params=network_params, max_sequence_length=args.max_sequence_length)
    LOG.info("Saving model at %s", args.output_model_path)
    model.save(args.output_model_path) 
开发者ID:undeadpixel,项目名称:reinvent-randomized,代码行数:25,代码来源:create_model.py

示例2: train

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import Model [as 别名]
def train(self):
        env = A2C.make_all_environments(self.args.num_envs, self.env_class, self.args.env_name,
                                        self.args.env_seed)

        print("\n\nBuilding the model...")
        self.model.build(env.observation_space.shape, env.action_space.n)
        print("Model is built successfully\n\n")

        with open(self.args.experiment_dir + self.args.env_name + '.pkl', 'wb') as f:
            pickle.dump((env.observation_space.shape, env.action_space.n), f, pickle.HIGHEST_PROTOCOL)

        print('Training...')
        try:
            # Produce video only if monitor method is implemented.
            try:
                if self.args.record_video_every != -1:
                    env.monitor(is_monitor=True, is_train=True, experiment_dir=self.args.experiment_dir,
                                record_video_every=self.args.record_video_every)
            except:
                pass
            self.trainer.train(env)
        except KeyboardInterrupt:
            print('Error occured..\n')
            self.trainer.save()
            env.close() 
开发者ID:MG2033,项目名称:A2C,代码行数:27,代码来源:A2C.py

示例3: pre_rescaling

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import Model [as 别名]
def pre_rescaling(self, images, is_training=True):
        return inception_pre_rescaling(images, is_training)


# class GooglenetModel(model.Model):

#     def __init__(self):
#         super(GooglenetModel, self).__init__('googlenet', 224, 32, 0.005) 
开发者ID:balancap,项目名称:tf-imagenet,代码行数:10,代码来源:inception.py

示例4: __init__

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import Model [as 别名]
def __init__(self, sess, args):
        self.args = args
        self.model = Model(sess,
                           optimizer_params={
                               'learning_rate': args.learning_rate, 'alpha': 0.99, 'epsilon': 1e-5}, args=self.args)
        self.trainer = Trainer(sess, self.model, args=self.args)
        self.env_class = A2C.env_name_parser(self.args.env_class) 
开发者ID:MG2033,项目名称:A2C,代码行数:9,代码来源:A2C.py

示例5: nasnet_cifar_arg_scope

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import Model [as 别名]
def nasnet_cifar_arg_scope(weight_decay=5e-4,
                           batch_norm_decay=0.9,
                           batch_norm_epsilon=1e-5):
  """Defines the default arg scope for the NASNet-A Cifar model.

  Args:
    weight_decay: The weight decay to use for regularizing the model.
    batch_norm_decay: Decay for batch norm moving average.
    batch_norm_epsilon: Small float added to variance to avoid dividing by zero
      in batch norm.
  Returns:
    An `arg_scope` to use for the NASNet Cifar Model.
  """
  batch_norm_params = {
      # Decay for the moving averages.
      'decay': batch_norm_decay,
      # epsilon to prevent 0s in variance.
      'epsilon': batch_norm_epsilon,
      'scale': True,
      'fused': True,
  }
  weights_regularizer = tf.contrib.layers.l2_regularizer(weight_decay)
  weights_initializer = tf.contrib.layers.variance_scaling_initializer(
      mode='FAN_OUT')
  with arg_scope(
      [slim.fully_connected, slim.conv2d, slim.separable_conv2d],
      weights_regularizer=weights_regularizer,
      weights_initializer=weights_initializer):
    with arg_scope([slim.fully_connected], activation_fn=None, scope='FC'):
      with arg_scope(
          [slim.conv2d, slim.separable_conv2d],
          activation_fn=None,
          biases_initializer=None):
        with arg_scope([slim.batch_norm], **batch_norm_params) as sc:
          return sc 
开发者ID:HewlettPackard,项目名称:dlcookbook-dlbs,代码行数:37,代码来源:nasnet_model.py

示例6: nasnet_mobile_arg_scope

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import Model [as 别名]
def nasnet_mobile_arg_scope(weight_decay=4e-5,
                            batch_norm_decay=0.9997,
                            batch_norm_epsilon=1e-3):
  """Defines the default arg scope for the NASNet-A Mobile ImageNet model.

  Args:
    weight_decay: The weight decay to use for regularizing the model.
    batch_norm_decay: Decay for batch norm moving average.
    batch_norm_epsilon: Small float added to variance to avoid dividing by zero
      in batch norm.
  Returns:
    An `arg_scope` to use for the NASNet Mobile Model.
  """
  batch_norm_params = {
      # Decay for the moving averages.
      'decay': batch_norm_decay,
      # epsilon to prevent 0s in variance.
      'epsilon': batch_norm_epsilon,
      'scale': True,
      'fused': True,
  }
  weights_regularizer = tf.contrib.layers.l2_regularizer(weight_decay)
  weights_initializer = tf.contrib.layers.variance_scaling_initializer(
      mode='FAN_OUT')
  with arg_scope(
      [slim.fully_connected, slim.conv2d, slim.separable_conv2d],
      weights_regularizer=weights_regularizer,
      weights_initializer=weights_initializer):
    with arg_scope([slim.fully_connected], activation_fn=None, scope='FC'):
      with arg_scope(
          [slim.conv2d, slim.separable_conv2d],
          activation_fn=None,
          biases_initializer=None):
        with arg_scope([slim.batch_norm], **batch_norm_params) as sc:
          return sc 
开发者ID:HewlettPackard,项目名称:dlcookbook-dlbs,代码行数:37,代码来源:nasnet_model.py

示例7: nasnet_large_arg_scope

# 需要导入模块: from models import model [as 别名]
# 或者: from models.model import Model [as 别名]
def nasnet_large_arg_scope(weight_decay=5e-5,
                           batch_norm_decay=0.9997,
                           batch_norm_epsilon=1e-3):
  """Defines the default arg scope for the NASNet-A Large ImageNet model.

  Args:
    weight_decay: The weight decay to use for regularizing the model.
    batch_norm_decay: Decay for batch norm moving average.
    batch_norm_epsilon: Small float added to variance to avoid dividing by zero
      in batch norm.
  Returns:
    An `arg_scope` to use for the NASNet Large Model.
  """
  batch_norm_params = {
      # Decay for the moving averages.
      'decay': batch_norm_decay,
      # epsilon to prevent 0s in variance.
      'epsilon': batch_norm_epsilon,
      'scale': True,
      'fused': True,
  }
  weights_regularizer = tf.contrib.layers.l2_regularizer(weight_decay)
  weights_initializer = tf.contrib.layers.variance_scaling_initializer(
      mode='FAN_OUT')
  with arg_scope(
      [slim.fully_connected, slim.conv2d, slim.separable_conv2d],
      weights_regularizer=weights_regularizer,
      weights_initializer=weights_initializer):
    with arg_scope([slim.fully_connected], activation_fn=None, scope='FC'):
      with arg_scope(
          [slim.conv2d, slim.separable_conv2d],
          activation_fn=None,
          biases_initializer=None):
        with arg_scope([slim.batch_norm], **batch_norm_params) as sc:
          return sc 
开发者ID:HewlettPackard,项目名称:dlcookbook-dlbs,代码行数:37,代码来源:nasnet_model.py


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