0. Metadata/Provenance study.set_user_attr('pykeen_version', get_version()) study.set_user_attr('pykeen_git_hash', get_git_hash()) # 1. Dataset # FIXME difference between dataset class and string # FIXME how to handle if dataset or factories were set? Should have been # part of https://github.com/mali-git/POEM_develop/pull/483 study.set_user_attr('dataset', dataset) # 2. Model model: Type[Model] = get_model_cls(model) study.set_user_attr('model', normalize_string(model.__name__)) logger.info(f'Using model: {model}') # 3. Loss loss: Type[Loss] = model.loss_default if loss is None else get_loss_cls(loss) study.set_user_attr('loss', normalize_string(loss.__name__, suffix=_LOSS_SUFFIX)) logger.info(f'Using loss: {loss}') # 4. Regularizer regularizer: Type[Regularizer] = ( model.regularizer_default if regularizer is None else get_regularizer_cls(regularizer) ) study.set_user_attr('regularizer', regularizer.get_normalized_name()) logger.info(f'Using regularizer: {regularizer}') # 5. Optimizer optimizer: Type[Optimizer] = get_optimizer_cls(optimizer) study.set_user_attr('optimizer', normalize_string(optimizer.__name__)) logger.info(f'Using optimizer: {optimizer}') # 6. Training Loop training_loop: Type[TrainingLoop] = get_training_loop_cls(training_loop) study.set_user_attr('training_loop', training_loop.get_normalized_name()) logger.info(f'Using training loop: {training_loop}') if training_loop is SLCWATrainingLoop: negative_sampler: Optional[Type[NegativeSampler]] = get_negative_sampler_cls(negative_sampler) study.set_user_attr('negative_sampler', negative_sampler.get_normalized_name()) logger.info(f'Using negative sampler: {negative_sampler}') else: negative_sampler: Optional[Type[NegativeSampler]] = None # 7. Training stopper: Type[Stopper] = get_stopper_cls(stopper) if stopper is EarlyStopper and training_kwargs_ranges and 'epochs' in training_kwargs_ranges: raise ValueError('can not use early stopping while optimizing epochs') # 8. Evaluation evaluator: Type[Evaluator] = get_evaluator_cls(evaluator) study.set_user_attr('evaluator', evaluator.get_normalized_name()) logger.info(f'Using evaluator: {evaluator}') if metric is None: metric = 'adjusted_mean_rank' study.set_user_attr('metric', metric) logger.info(f'Attempting to {direction} {metric}')解释
时间: 2024-04-25 15:26:20 浏览: 125
gss_mech_switch.rar_V2
这段代码是关于PyKEEN的元数据和源数据的设置。在这里,它设置了以下内容:
1. 数据集
2. 模型
3. 损失函数
4. 正则化器
5. 优化器
6. 训练循环
7. 训练
8. 评估器和度量指标
在设置每个内容时,代码都会使用一些辅助函数来获取相应的类,并将其规范化为可读的字符串。这些信息将被保存在study对象的user_attrs属性中。
阅读全文