autogl.module.train
-
class
autogl.module.train.
BaseGraphClassificationTrainer
(encoder: Union[autogl.module.model.pyg.base.BaseAutoModel, autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, str, None] = None, decoder: Union[autogl.module.model.decoders.base_decoder.BaseDecoderMaintainer, str, None] = None, num_features: Optional[int] = None, num_classes: Optional[int] = None, num_graph_features: int = 0, last_dim: Union[int, str] = 'auto', device: Union[torch.device, str, None] = None, feval: Union[Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = (<class 'autogl.module.train.evaluation.Acc'>,), loss: str = 'nll_loss')[source]
-
class
autogl.module.train.
BaseNodeClassificationTrainer
(encoder: Union[autogl.module.model.pyg.base.BaseAutoModel, autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, str, None], decoder: Union[autogl.module.model.decoders.base_decoder.BaseDecoderMaintainer, str, None], num_features: int, num_classes: int, device: Union[torch.device, str, None] = None, feval: Union[Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = (<class 'autogl.module.train.evaluation.Acc'>,), loss: str = 'nll_loss')[source]
-
class
autogl.module.train.
BaseNodeClassificationHetTrainer
(model: Union[autogl.module.model.pyg.base.BaseAutoModel, str], dataset: None, num_features: int, num_classes: int, device: Union[torch.device, str, None] = 'auto', feval: Union[Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = (<class 'autogl.module.train.evaluation.Acc'>,), loss: str = 'nll_loss')[source] Base class of trainer for classification tasks
-
class
autogl.module.train.
BaseLinkPredictionTrainer
(encoder: Union[autogl.module.model.pyg.base.BaseAutoModel, autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, str, None] = None, decoder: Union[autogl.module.model.decoders.base_decoder.BaseDecoderMaintainer, str, None] = None, num_features: Optional[int] = None, last_dim: Union[int, str] = 'auto', device: Union[torch.device, str, None] = None, feval: Union[Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = (<class 'autogl.module.train.evaluation.Acc'>,), loss: str = 'nll_loss')[source]
-
class
autogl.module.train.
GraphClassificationFullTrainer
(model: Union[Tuple[autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, autogl.module.model.decoders.base_decoder.BaseDecoderMaintainer], autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, autogl.module.model.pyg.base.BaseAutoModel, str] = None, num_features: int = None, num_classes: int = None, num_graph_features: int = 0, optimizer: Type[torch.optim.optimizer.Optimizer] = <class 'torch.optim.adam.Adam'>, lr: float = 0.0001, max_epoch: int = 100, batch_size: int = 64, num_workers: int = 0, early_stopping_round: int = 7, weight_decay: float = 0.0001, device: Union[str, torch.device] = 'auto', init: bool = False, feval=[<class 'autogl.module.train.evaluation.Logloss'>], loss='nll_loss', lr_scheduler_type=None, criterion=None, *args, **kwargs)[source] The graph classification trainer.
Used to automatically train the graph classification problem.
Parameters: - model – Models can be
str
,autogl.module.model.BaseAutoModel
,autogl.module.model.encoders.BaseEncoderMaintainer
or a tuple of (encoder, decoder) if need to specify both encoder and decoder. Encoder can bestr
orautogl.module.model.encoders.BaseEncoderMaintainer
, and decoder can bestr
orautogl.module.model.decoders.BaseDecoderMaintainer
. If only encoder is specified, decoder will be default to “logsoftmax” - num_features (int (Optional)) – The number of features in dataset. default None
- num_classes (int (Optional)) – The number of classes. default None
- num_graph_features (int (Optional)) – The number of graph level features. default 0.
- optimizer (
Optimizer
ofstr
) – The (name of) optimizer used to train and predict. default torch.optim.Adam - lr (
float
) – The learning rate of node classification task. default 1e-4 - max_epoch (
int
) – The max number of epochs in training. default 100 - early_stopping_round (
int
) – The round of early stop. default 100 - weight_decay (
float
) – weight decay ratio, default 1e-4 - device (
torch.device
orstr
) – The device where model will be running on. - init (
bool
) – If True(False), the model will (not) be initialized. - feval ((Sequence of)
Evaluation
orstr
) – The evaluation functions, default[LogLoss]
- loss (
str
) – The loss used. Defaultnll_loss
. - lr_scheduler_type (
str
(Optional)) – The lr scheduler type used. Default None.
-
duplicate_from_hyper_parameter
(hp, encoder='same', decoder='same', restricted=True)[source] The function of duplicating a new instance from the given hyperparameter.
Parameters: - hp (
dict
.) – The hyperparameter used in the new instance. Should contain 3 keys “trainer”, “encoder” “decoder”, with corresponding hyperparameters as values. - model (The new model) – Models can be
str
,autogl.module.model.BaseAutoModel
,autogl.module.model.encoders.BaseEncoderMaintainer
or a tuple of (encoder, decoder) if need to specify both encoder and decoder. Encoder can bestr
orautogl.module.model.encoders.BaseEncoderMaintainer
, and decoder can bestr
orautogl.module.model.decoders.BaseDecoderMaintainer
. - restricted (
bool
.) – If False(True), the hyperparameter should (not) be updated from origin hyperparameter.
Returns: self – A new instance of trainer.
Return type: autogl.train.GraphClassificationTrainer
- hp (
-
evaluate
(dataset, mask='val', feval=None)[source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset (The graph classification dataset used to be evaluated.) –
- mask (
train
,val
, ortest
.) – The dataset mask. - feval (
str
.) – The evaluation method used in this function.
Returns: res
Return type: The evaluation result on the given dataset.
-
get_valid_score
(return_major=True)[source] The function of getting the valid score.
Parameters: return_major ( bool
.) – If True, the return only consists of the major result. If False, the return consists of the all results.Returns: result Return type: The valid score in training stage.
-
predict
(dataset, mask='test')[source] The function of predicting on the given dataset.
Parameters: - dataset (The graph classification dataset used to be predicted.) –
- mask (
train
,val
, ortest
.) – The dataset mask.
Returns: Return type: The prediction result of
predict_proba
.
-
predict_proba
(dataset, mask='test', in_log_format=False)[source] The function of predicting the probability on the given dataset.
Parameters: - dataset (The graph classification dataset used to be predicted.) –
- mask (
train
,val
, ortest
.) – The dataset mask. - in_log_format (
bool
.) – If True(False), the probability will (not) be log format.
Returns: Return type: The prediction result.
-
train
(dataset, keep_valid_result=True)[source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset (The graph classification dataset used to be trained.) –
- keep_valid_result (
bool
) – If True(False), save the validation result after training.
Returns: self – A reference of current trainer.
Return type: autogl.train.GraphClassificationTrainer
- model – Models can be
-
class
autogl.module.train.
NodeClassificationFullTrainer
(model: Union[Tuple[autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, autogl.module.model.decoders.base_decoder.BaseDecoderMaintainer], autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, autogl.module.model.pyg.base.BaseAutoModel, str] = None, num_features: Optional[int] = None, num_classes: Optional[int] = None, optimizer: Union[str, Type[torch.optim.optimizer.Optimizer]] = <class 'torch.optim.adam.Adam'>, lr: float = 0.0001, max_epoch: int = 100, early_stopping_round: int = 100, weight_decay: float = 0.0001, device: Union[torch.device, str] = 'auto', init: bool = False, feval: Iterable[Type[autogl.module.train.evaluation.Evaluation]] = [<class 'autogl.module.train.evaluation.Logloss'>], loss: Union[Callable, str] = 'nll_loss', lr_scheduler_type: Optional[str] = None, **kwargs)[source] The node classification trainer.
Used to automatically train the node classification problem.
Parameters: - model – Models can be
str
,autogl.module.model.BaseAutoModel
,autogl.module.model.encoders.BaseEncoderMaintainer
or a tuple of (encoder, decoder) if need to specify both encoder and decoder. Encoder can bestr
orautogl.module.model.encoders.BaseEncoderMaintainer
, and decoder can bestr
orautogl.module.model.decoders.BaseDecoderMaintainer
. If only encoder is specified, decoder will be default to “logsoftmax” - num_features (int (Optional)) – The number of features in dataset. default None
- num_classes (int (Optional)) – The number of classes. default None
- optimizer (
Optimizer
ofstr
) – The (name of) optimizer used to train and predict. default torch.optim.Adam - lr (
float
) – The learning rate of node classification task. default 1e-4 - max_epoch (
int
) – The max number of epochs in training. default 100 - early_stopping_round (
int
) – The round of early stop. default 100 - weight_decay (
float
) – weight decay ratio, default 1e-4 - device (
torch.device
orstr
) – The device where model will be running on. - init (
bool
) – If True(False), the model will (not) be initialized. - feval ((Sequence of)
Evaluation
orstr
) – The evaluation functions, default[LogLoss]
- loss (
str
) – The loss used. Defaultnll_loss
. - lr_scheduler_type (
str
(Optional)) – The lr scheduler type used. Default None.
-
duplicate_from_hyper_parameter
(hp: dict, model=None, restricted=True)[source] The function of duplicating a new instance from the given hyperparameter.
Parameters: - hp (
dict
.) – The hyperparameter used in the new instance. Should contain 3 keys “trainer”, “encoder” “decoder”, with corresponding hyperparameters as values. - model – Models can be
str
,autogl.module.model.BaseAutoModel
,autogl.module.model.encoders.BaseEncoderMaintainer
or a tuple of (encoder, decoder) if need to specify both encoder and decoder. Encoder can bestr
orautogl.module.model.encoders.BaseEncoderMaintainer
, and decoder can bestr
orautogl.module.model.decoders.BaseDecoderMaintainer
. - restricted (
bool
.) – If False(True), the hyperparameter should (not) be updated from origin hyperparameter.
Returns: self – A new instance of trainer.
Return type: autogl.train.NodeClassificationTrainer
- hp (
-
evaluate
(dataset, mask=None, feval=None)[source] Evaluate on the given dataset.
Parameters: - dataset (The node classification dataset used to be evaluated.) –
- mask (
train
,val
, ortest
.) – The dataset mask. - feval (
str
.) – The evaluation method used in this function.
Returns: res
Return type: The evaluation result on the given dataset.
-
get_valid_score
(return_major=True)[source] The function of getting the valid score.
Parameters: return_major ( bool
.) – If True, the return only consists of the major result. If False, the return consists of the all results.Returns: result Return type: The valid score in training stage.
-
predict
(dataset, mask=None)[source] Predict on the given dataset using specified mask.
Parameters: - dataset (The node classification dataset used to be predicted.) –
- mask (
train
,val
, ortest
.) – The dataset mask.
Returns: Return type: The prediction result.
-
predict_proba
(dataset, mask=None, in_log_format=False)[source] Predict the probability on the given dataset using specified mask.
Parameters: - dataset (The node classification dataset used to be predicted.) –
- mask (
train
,val
,test
, orTensor
.) – The dataset mask. - in_log_format (
bool
.) – If True(False), the probability will (not) be log format.
Returns: Return type: The prediction result.
-
train
(dataset, keep_valid_result=True, train_mask=None)[source] Train on the given dataset.
Parameters: - dataset (The node classification dataset used to be trained.) –
- keep_valid_result (
bool
) – If True(False), save the validation result after training. - train_mask (The mask for training data) –
Returns: self – A reference of current trainer.
Return type: autogl.train.NodeClassificationTrainer
- model – Models can be
-
class
autogl.module.train.
NodeClassificationHetTrainer
(model: Union[autogl.module.model.pyg.base.BaseAutoModel, str] = None, dataset=None, num_features=None, num_classes=None, optimizer=<class 'torch.optim.adamw.AdamW'>, lr=0.0001, max_epoch=100, early_stopping_round=100, weight_decay=0.0001, device='auto', init=False, feval=[<class 'autogl.module.train.evaluation.Logloss'>], loss='nll_loss', lr_scheduler_type=None, *args, **kwargs)[source] The heterogeneous node classification trainer.
Parameters: - model (
autogl.module.model.BaseAutoModel
) – Currently Heterogeneous trainer doesn’t support decoupled model setting. - num_features (
int
(Optional)) – The number of features in dataset. default None - num_classes (
int
(Optional)) – The number of classes. default None - optimizer (
Optimizer
ofstr
) – The (name of) optimizer used to train and predict. default torch.optim.Adam - lr (
float
) – The learning rate of node classification task. default 1e-4 - max_epoch (
int
) – The max number of epochs in training. default 100 - early_stopping_round (
int
) – The round of early stop. default 100 - weight_decay (
float
) – weight decay ratio, default 1e-4 - device (
torch.device
orstr
) – The device where model will be running on. - init (
bool
) – If True(False), the model will (not) be initialized. - feval ((Sequence of)
Evaluation
orstr
) – The evaluation functions, default[LogLoss]
- loss (
str
) – The loss used. Defaultnll_loss
. - lr_scheduler_type (
str
(Optional)) – The lr scheduler type used. Default None.
-
duplicate_from_hyper_parameter
(hp: dict, model=None, restricted=True)[source] The function of duplicating a new instance from the given hyperparameter.
Parameters: - hp (
dict
.) – The hyperparameter used in the new instance. Should contain 2 keys “trainer”, “encoder” with corresponding hyperparameters as values. - model (
autogl.module.model.BaseAutoModel
) – Currently Heterogeneous trainer doesn’t support decoupled model setting. If only encoder is specified, decoder will be default to “logsoftmax” - restricted (
bool
.) – If False(True), the hyperparameter should (not) be updated from origin hyperparameter.
Returns: self – A new instance of trainer.
Return type: autogl.train.NodeClassificationTrainer
- hp (
-
evaluate
(dataset, mask='val', feval=None)[source] The function of training on the given dataset and keeping valid result. :param dataset: :type dataset: The node classification dataset used to be evaluated. :param mask: The dataset mask. :type mask:
train
,val
, ortest
. :param feval: The evaluation method used in this function. :type feval:str
.Returns: res Return type: The evaluation result on the given dataset.
-
get_valid_score
(return_major=True)[source] The function of getting the valid score.
Parameters: return_major ( bool
.) – If True, the return only consists of the major result. If False, the return consists of the all results.Returns: result Return type: The valid score in training stage.
-
predict
(dataset, mask='test')[source] The function of predicting on the given dataset. :param dataset: :type dataset: The node classification dataset used to be predicted. :param mask: The dataset mask. :type mask:
train
,val
, ortest
.Returns: Return type: The prediction result of predict_proba
.
-
predict_proba
(dataset, mask='test', in_log_format=False)[source] The function of predicting the probability on the given dataset. :param dataset: :type dataset: The node classification dataset used to be predicted. :param mask: The dataset mask. :type mask:
train
,val
,test
, orTensor
. :param in_log_format: If True(False), the probability will (not) be log format. :type in_log_format:bool
.Returns: Return type: The prediction result.
-
to
(new_device)[source] Transfer the trainer to another device :param device: The device this trainer will use :type device: str or torch.device
-
train
(dataset, keep_valid_result=True, train_mask='train')[source] The function of training on the given dataset and keeping valid result. :param dataset: :type dataset: The node classification dataset used to be trained. :param keep_valid_result: If True(False), save the validation result after training. :type keep_valid_result:
bool
:param train_mask: :type train_mask: The mask for training dataReturns: self – A reference of current trainer. Return type: autogl.train.NodeClassificationTrainer
- model (
-
class
autogl.module.train.
LinkPredictionTrainer
(model: Union[Tuple[autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, autogl.module.model.decoders.base_decoder.BaseDecoderMaintainer], autogl.module.model.encoders.base_encoder.BaseEncoderMaintainer, autogl.module.model.pyg.base.BaseAutoModel, str] = None, num_features=None, optimizer=<class 'torch.optim.adam.Adam'>, lr=0.0001, max_epoch=100, early_stopping_round=101, weight_decay=0.0001, device='auto', init=False, feval=[<class 'autogl.module.train.evaluation.Auc'>], loss='binary_cross_entropy_with_logits', lr_scheduler_type=None, *args, **kwargs)[source] The link prediction trainer.
Used to automatically train the link prediction problem.
Parameters: - model – Models can be
str
,autogl.module.model.BaseAutoModel
,autogl.module.model.encoders.BaseEncoderMaintainer
or a tuple of (encoder, decoder) if need to specify both encoder and decoder. Encoder can bestr
orautogl.module.model.encoders.BaseEncoderMaintainer
, and decoder can bestr
orautogl.module.model.decoders.BaseDecoderMaintainer
. If only encoder is specified, decoder will be default to “logsoftmax” - num_features (int (Optional)) – The number of features in dataset. default None
- optimizer (
Optimizer
ofstr
) – The (name of) optimizer used to train and predict. default torch.optim.Adam - lr (
float
) – The learning rate of node classification task. default 1e-4 - max_epoch (
int
) – The max number of epochs in training. default 100 - early_stopping_round (
int
) – The round of early stop. default 100 - weight_decay (
float
) – weight decay ratio, default 1e-4 - device (
torch.device
orstr
) – The device where model will be running on. - init (
bool
) – If True(False), the model will (not) be initialized. - feval ((Sequence of)
Evaluation
orstr
) – The evaluation functions, default[LogLoss]
- loss (
str
) – The loss used. Defaultnll_loss
. - lr_scheduler_type (
str
(Optional)) – The lr scheduler type used. Default None.
-
duplicate_from_hyper_parameter
(hp: dict, model=None, restricted=True)[source] The function of duplicating a new instance from the given hyperparameter.
Parameters: - hp (
dict
.) – The hyperparameter used in the new instance. Should contain 3 keys “trainer”, “encoder” “decoder”, with corresponding hyperparameters as values. - model (The new model) – Models can be
str
,autogl.module.model.BaseAutoModel
,autogl.module.model.encoders.BaseEncoderMaintainer
or a tuple of (encoder, decoder) if need to specify both encoder and decoder. Encoder can bestr
orautogl.module.model.encoders.BaseEncoderMaintainer
, and decoder can bestr
orautogl.module.model.decoders.BaseDecoderMaintainer
. - restricted (
bool
.) – If False(True), the hyperparameter should (not) be updated from origin hyperparameter.
Returns: self – A new instance of trainer.
Return type: autogl.train.LinkPredictionTrainer
- hp (
-
evaluate
(dataset, mask=None, feval=None)[source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset (The link prediction dataset used to be evaluated.) –
- mask (
train
,val
, ortest
.) – The dataset mask. - feval (
str
.) – The evaluation method used in this function.
Returns: res
Return type: The evaluation result on the given dataset.
-
get_valid_score
(return_major=True)[source] The function of getting the valid score.
Parameters: return_major ( bool
.) – If True, the return only consists of the major result. If False, the return consists of the all results.Returns: result Return type: The valid score in training stage.
-
predict
(dataset, mask=None)[source] The function of predicting on the given dataset.
Parameters: - dataset (The link prediction dataset used to be predicted.) –
- mask (
train
,val
, ortest
.) – The dataset mask.
:param .. Note:: Deprecated, this function will be removed in the future.:
Returns: Return type: The prediction result of predict_proba
.
-
predict_proba
(dataset, mask=None, in_log_format=False)[source] Predict the probability on the given dataset. :param dataset: :type dataset: The dataset used in predicting. :param mask: The dataset mask. :type mask: train, val, or test. :param in_log_format: If True(False), the probability will (not) be log format. :type in_log_format: bool.
Returns: Return type: The prediction result.
-
train
(dataset, keep_valid_result=True)[source] train on the given dataset
Parameters: - dataset (The link prediction dataset used to be trained.) –
- keep_valid_result (
bool
) – If True(False), save the validation result after training.
Returns: self – A reference of current trainer.
Return type: autogl.train.LinkPredictionTrainer
- model – Models can be
-
class
autogl.module.train.
NodeClassificationGraphSAINTTrainer
(model: Union[autogl.module.model.pyg.base.BaseAutoModel, str], num_features: int, num_classes: int, optimizer: Union[Type[torch.optim.optimizer.Optimizer], str, None] = Ellipsis, lr: float = 0.0001, max_epoch: int = 100, early_stopping_round: int = 100, weight_decay: float = 0.0001, device: Optional[torch.device] = None, init: bool = True, feval: Union[Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = (<class 'autogl.module.train.evaluation.MicroF1'>,), loss: str = 'nll_loss', lr_scheduler_type: Optional[str] = None, **kwargs)[source] The node classification trainer utilizing GraphSAINT technique.
Parameters: - model (
BaseModel
orstr
) – The name or class of model adopted - num_features (
int
) – number of features for each node provided by dataset - num_classes (
int
) – number of classes to classify - optimizer (
Optimizer
ofstr
) – The (name of) optimizer used to train and predict. - lr (
float
) – The learning rate of link prediction task. - max_epoch (
int
) – The max number of epochs in training. - early_stopping_round (
int
) – The round of early stop. - weight_decay (
float
) – The weight decay argument for optimizer - device (
torch.device
orstr
) – The device where model will be running on. - init (
bool
) – If True(False), the model will (not) be initialized. - feval (
str
.) – The evaluation method adopted in this function.
-
duplicate_from_hyper_parameter
(hp: Dict[str, Any], model: Optional[autogl.module.model.pyg.base.BaseAutoModel] = None) → autogl.module.train.node_classification_trainer.node_classification_sampled_trainer.NodeClassificationGraphSAINTTrainer[source] The function of duplicating a new instance from the given hyper-parameter.
Parameters: - hp (
dict
.) – The hyper-parameter settings for the new instance. - model (
BaseModel
) – The name or class of model adopted
Returns: instance – A new instance of trainer.
Return type: NodeClassificationGraphSAINTTrainer
- hp (
-
evaluate
(dataset, mask: Optional[str] = None, feval: Union[None, Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = None) → Sequence[float][source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask. - feval (
str
.) – The evaluation method adopted in this function.
Returns: result
Return type: The evaluation result on the given dataset.
-
get_valid_score
(return_major: bool = True) → Union[Tuple[float, bool], Tuple[Sequence[float], Sequence[bool]]][source] The function of getting the valid score.
Parameters: return_major ( bool
.) – If True, the return only consists of the major result. If False, the return consists of the all results.Returns: result Return type: The valid score.
-
predict
(dataset, mask: Optional[str] = None) → torch.Tensor[source] The function of predicting on the given dataset.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask.
Returns: Return type: The prediction result of
predict_proba
.
-
predict_proba
(dataset, mask: Optional[str] = None, in_log_format: bool = False)[source] The function of predicting the probability on the given dataset.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask. - in_log_format (
bool
.) – If True(False), the probability will (not) be log format.
Returns: Return type: The prediction result.
-
to
(device: torch.device)[source] Transfer the trainer to another device :param device: The device this trainer will use :type device: str or torch.device
-
train
(dataset, keep_valid_result: bool = True)[source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- keep_valid_result (
bool
) – If True(False), save the validation result after training.
Returns: Return type: None
- model (
-
class
autogl.module.train.
NodeClassificationLayerDependentImportanceSamplingTrainer
(model: Union[autogl.module.model.pyg.base.BaseAutoModel, str], num_features: int, num_classes: int, optimizer: Union[Type[torch.optim.optimizer.Optimizer], str, None] = Ellipsis, lr: float = 0.0001, max_epoch: int = 100, early_stopping_round: int = 100, weight_decay: float = 0.0001, device: Optional[torch.device] = None, init: bool = True, feval: Union[Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = (<class 'autogl.module.train.evaluation.MicroF1'>,), loss: str = 'nll_loss', lr_scheduler_type: Optional[str] = None, **kwargs)[source] The node classification trainer utilizing Layer dependent importance sampling technique.
Parameters: - model (
BaseModel
orstr
) – The name or class of model adopted - num_features (
int
) – number of features for each node provided by dataset - num_classes (
int
) – number of classes to classify - optimizer (
Optimizer
ofstr
) – The (name of) optimizer used to train and predict. - lr (
float
) – The learning rate of link prediction task. - max_epoch (
int
) – The max number of epochs in training. - early_stopping_round (
int
) – The round of early stop. - weight_decay (
float
) – The weight decay argument for optimizer - device (
torch.device
orstr
) – The device where model will be running on. - init (
bool
) – If True(False), the model will (not) be initialized. - feval (
str
.) – The evaluation method adopted in this function.
-
duplicate_from_hyper_parameter
(hp: Dict[str, Any], model: Optional[autogl.module.model.pyg.base.BaseAutoModel] = None) → autogl.module.train.node_classification_trainer.node_classification_sampled_trainer.NodeClassificationLayerDependentImportanceSamplingTrainer[source] The function of duplicating a new instance from the given hyper-parameter.
Parameters: - hp (
dict
.) – The hyper-parameter settings for the new instance. - model (
BaseModel
) – The name or class of model adopted
Returns: instance – A new instance of trainer.
Return type: NodeClassificationLayerDependentImportanceSamplingTrainer
- hp (
-
evaluate
(dataset, mask: Optional[str] = None, feval: Union[None, Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = None) → Sequence[float][source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask. - feval (
str
.) – The evaluation method adopted in this function.
Returns: result
Return type: The evaluation result on the given dataset.
-
get_valid_score
(return_major: bool = True) → Union[Tuple[float, bool], Tuple[Sequence[float], Sequence[bool]]][source] The function of getting the valid score.
Parameters: return_major ( bool
.) – If True, the return only consists of the major result. If False, the return consists of the all results.Returns: result Return type: The valid score.
-
predict
(dataset, mask: Optional[str] = None) → torch.Tensor[source] The function of predicting on the given dataset.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask.
Returns: Return type: The prediction result of
predict_proba
.
-
predict_proba
(dataset, mask: Optional[str] = None, in_log_format: bool = False)[source] The function of predicting the probability on the given dataset.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask. - in_log_format (
bool
.) – If True(False), the probability will (not) be log format.
Returns: Return type: The prediction result.
-
to
(device: torch.device)[source] Transfer the trainer to another device :param device: The device this trainer will use :type device: str or torch.device
-
train
(dataset, keep_valid_result: bool = True)[source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- keep_valid_result (
bool
) – If True(False), save the validation result after training.
Returns: Return type: None
- model (
-
class
autogl.module.train.
NodeClassificationNeighborSamplingTrainer
(model: Union[autogl.module.model.pyg.base.BaseAutoModel, str], num_features: int, num_classes: int, optimizer: Union[Type[torch.optim.optimizer.Optimizer], str, None] = Ellipsis, lr: float = 0.0001, max_epoch: int = 100, early_stopping_round: int = 100, weight_decay: float = 0.0001, device: Optional[torch.device] = None, init: bool = True, feval: Union[Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = (<class 'autogl.module.train.evaluation.Logloss'>,), loss: str = 'nll_loss', lr_scheduler_type: Optional[str] = None, **kwargs)[source] The node classification trainer utilizing Layer dependent importance sampling technique.
Parameters: - model (
BaseModel
orstr
) – The name or class of model adopted - num_features (
int
) – number of features for each node provided by dataset - num_classes (
int
) – number of classes to classify - optimizer (
Optimizer
ofstr
) – The (name of) optimizer used to train and predict. - lr (
float
) – The learning rate of link prediction task. - max_epoch (
int
) – The max number of epochs in training. - early_stopping_round (
int
) – The round of early stop. - weight_decay (
float
) – The weight decay argument for optimizer - device (
torch.device
orstr
) – The device where model will be running on. - init (
bool
) – If True(False), the model will (not) be initialized. - feval (
str
.) – The evaluation method adopted in this function.
-
duplicate_from_hyper_parameter
(hp: Dict[str, Any], model: Optional[autogl.module.model.pyg.base.BaseAutoModel] = None) → autogl.module.train.node_classification_trainer.node_classification_sampled_trainer.NodeClassificationNeighborSamplingTrainer[source] The function of duplicating a new instance from the given hyper-parameter.
Parameters: - hp (
dict
.) – The hyper-parameter settings for the new instance. - model (
BaseModel
) – The name or class of model adopted
Returns: instance – A new instance of trainer.
Return type: NodeClassificationLayerDependentImportanceSamplingTrainer
- hp (
-
evaluate
(dataset, mask: Optional[str] = None, feval: Union[None, Sequence[str], Sequence[Type[autogl.module.train.evaluation.Evaluation]]] = None) → Sequence[float][source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask. - feval (
str
.) – The evaluation method adopted in this function.
Returns: result
Return type: The evaluation result on the given dataset.
-
get_valid_score
(return_major: bool = True) → Union[Tuple[float, bool], Tuple[Sequence[float], Sequence[bool]]][source] The function of getting the valid score.
Parameters: return_major ( bool
.) – If True, the return only consists of the major result. If False, the return consists of the all results.Returns: result Return type: The valid score.
-
predict
(dataset, mask: Optional[str] = None) → torch.Tensor[source] The function of predicting on the given dataset.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask.
Returns: Return type: The prediction result of
predict_proba
.
-
predict_proba
(dataset, mask: Optional[str] = None, in_log_format: bool = False)[source] The function of predicting the probability on the given dataset.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- mask – The str of
train
,val
, ortest
, representing the identifier for specific dataset mask. - in_log_format (
bool
.) – If True(False), the probability will (not) be log format.
Returns: Return type: The prediction result.
-
to
(device: torch.device)[source] Transfer the trainer to another device :param device: The device this trainer will use :type device: str or torch.device
-
train
(dataset, keep_valid_result: bool = True)[source] The function of training on the given dataset and keeping valid result.
Parameters: - dataset – The dataset containing conventional data of integral graph adopted to train for node classification.
- keep_valid_result (
bool
) – If True(False), save the validation result after training.
Returns: Return type: None
- model (