本文整理匯總了Python中utils.utils.get_args方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.get_args方法的具體用法?Python utils.get_args怎麽用?Python utils.get_args使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils.utils
的用法示例。
在下文中一共展示了utils.get_args方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from utils import utils [as 別名]
# 或者: from utils.utils import get_args [as 別名]
def main():
# capture the config path from the run arguments
# then process the json configuration file
try:
args = get_args()
config = process_config(args.config)
except:
print("missing or invalid arguments")
exit(0)
# create the experiments dirs
create_dirs([config.callbacks.tensorboard_log_dir, config.callbacks.checkpoint_dir])
print('Create the data generator.')
data_loader = SimpleMnistDataLoader(config)
print('Create the model.')
model = SimpleMnistModel(config)
print('Create the trainer')
trainer = SimpleMnistModelTrainer(model.model, data_loader.get_train_data(), config)
print('Start training the model.')
trainer.train()
示例2: main
# 需要導入模塊: from utils import utils [as 別名]
# 或者: from utils.utils import get_args [as 別名]
def main():
args = get_args()
config = process_config(args.config)
# create the experiments dirs
create_dirs([config.cache_dir, config.model_dir,
config.log_dir, config.img_dir])
# logging to the file and stdout
logger = get_logger(config.log_dir, config.exp_name)
# fix random seed to reproduce results
random.seed(config.random_seed)
logger.info('Random seed: {:d}'.format(config.random_seed))
if config.method in ['src', 'jigsaw', 'rotate']:
model = AuxModel(config, logger)
else:
raise ValueError("Unknown method: %s" % config.method)
src_loader, val_loader = get_train_val_dataloader(config.datasets.src)
test_loader = get_test_dataloader(config.datasets.test)
tar_loader = None
if config.datasets.get('tar', None):
tar_loader = get_target_dataloader(config.datasets.tar)
if config.mode == 'train':
model.train(src_loader, tar_loader, val_loader, test_loader)
elif config.mode == 'test':
model.test(test_loader)
示例3: main
# 需要導入模塊: from utils import utils [as 別名]
# 或者: from utils.utils import get_args [as 別名]
def main():
# capture the config path from the run arguments
# then process the json configuration file
try:
args = get_args()
config = process_config(args.config)
except:
print("missing or invalid arguments")
exit(0)
# create the experiments dirs
create_dirs([config.summary_dir, config.checkpoint_dir])
# create tensorflow session
sess = tf.Session()
# create your data generator
data = DataGenerator(config)
# create an instance of the model you want
model = ExampleModel(config)
# create tensorboard logger
logger = Logger(sess, config)
# create trainer and pass all the previous components to it
trainer = ExampleTrainer(sess, model, data, config, logger)
#load model if exists
model.load(sess)
# here you train your model
trainer.train()
示例4: init
# 需要導入模塊: from utils import utils [as 別名]
# 或者: from utils.utils import get_args [as 別名]
def init() -> None:
"""
The main function of the project used to initialise all the required classes
used when training the model
"""
# get input arguments
args = get_args()
# get static config information
config = process_config()
# combine both into dictionary
config = {**config, **args}
# initialise model
model = RawModel(config)
# create your data generators for each mode
train_data = TFRecordDataLoader(config, mode="train")
val_data = TFRecordDataLoader(config, mode="val")
test_data = TFRecordDataLoader(config, mode="test")
# initialise the estimator
trainer = RawTrainer(config, model, train_data, val_data, test_data)
# start training
trainer.run()