本文整理汇总了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)
示例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()
示例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)
示例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)
示例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
示例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
示例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