本文整理汇总了Python中dataset.Dataset.get方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.get方法的具体用法?Python Dataset.get怎么用?Python Dataset.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_model
# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import get [as 别名]
def get_model(model_path):
hyperparams = utils.load_dict_from_json_file(os.path.join(model_path, "hyperparams"))
hyperparams['weights_initialization'] = "Zeros"
trainingparams = utils.load_dict_from_json_file(os.path.join(model_path, "trainingparams"))
dataset_name = trainingparams['dataset_name']
if dataset_name != "binarized_mnist":
raise ValueError("Invalid dataset. Only model trained on MNIST supported.")
#
# LOAD DATASET ####
dataset = Dataset.get(dataset_name)
if trainingparams['batch_size'] == -1:
trainingparams['batch_size'] = dataset['train']['length']
model = build_model(dataset, trainingparams, hyperparams, hyperparams['hidden_sizes'])
print("### Loading model | Hidden:{0} CondMask:{1} Activation:{2} ... ".format(
hyperparams['hidden_sizes'], hyperparams['use_cond_mask'], hyperparams['hidden_activation']), end=' ')
start_time = t.time()
load_model_params(model, model_path)
print(utils.get_done_text(start_time), "###")
return model, dataset_name, dataset
示例2: exit
# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import get [as 别名]
loaded_trainingparams = utils.load_dict_from_json_file(os.path.join(save_path_experiment, "trainingparams"))
if loaded_trainingparams != trainingparams or loaded_hyperparams != hyperparams:
print "The arguments provided are different than the one saved. Use --force if you are certain.\nQuitting."
exit()
resume_mode = True
else:
os.makedirs(save_path_experiment)
utils.save_dict_to_json_file(os.path.join(save_path_experiment, "hyperparams"), hyperparams)
utils.save_dict_to_json_file(os.path.join(save_path_experiment, "trainingparams"), trainingparams)
#
# LOAD DATASET ####
dataset = Dataset.get(dataset_name)
if trainingparams['batch_size'] == -1:
trainingparams['batch_size'] = dataset['train']['length']
#
# INITIALIZING LEARNER ####
if trainingparams['pre_training']:
model = build_model_layer_pretraining(dataset, trainingparams, hyperparams, trainingparams['pre_training_max_epoc'])
else:
model = build_model(dataset, trainingparams, hyperparams, hyperparams['hidden_sizes'])
trainer_status = None
# Not totally resumable if it was stopped during pre-training.
if resume_mode:
load_model_params(model, save_path_experiment)