From 00a4aa57d078d4ba77ef7de32568d7987c660742 Mon Sep 17 00:00:00 2001 From: troyyyyy Date: Tue, 9 Jan 2024 09:36:09 +0800 Subject: [PATCH] [FIX] unify docstring --- ablkit/bridge/simple_bridge.py | 14 +++--- ablkit/data/evaluation/base_metric.py | 2 +- ablkit/data/evaluation/reasoning_metric.py | 4 +- ablkit/data/evaluation/symbol_accuracy.py | 2 +- ablkit/learning/basic_nn.py | 50 +++++++++++----------- ablkit/learning/model_converter.py | 44 +++++++++---------- ablkit/utils/logger.py | 2 +- ablkit/utils/utils.py | 2 +- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/ablkit/bridge/simple_bridge.py b/ablkit/bridge/simple_bridge.py index b053902..79b6c81 100644 --- a/ablkit/bridge/simple_bridge.py +++ b/ablkit/bridge/simple_bridge.py @@ -233,19 +233,19 @@ class SimpleBridge(BaseBridge): ``self.metric_list``. If ``val_data`` is None, ``train_data`` will be used to validate the model during training time. Defaults to None. loops : int - Machine Learning part and Reasoning part will be iteratively optimized - for ``loops`` times, by default 50. + Learning part and Reasoning part will be iteratively optimized + for ``loops`` times. Defaults to 50. segment_size : Union[int, float] Data will be split into segments of this size and data in each segment - will be used together to train the model, by default 1.0. + will be used together to train the model. Defaults to 1.0. eval_interval : int The model will be evaluated every ``eval_interval`` loop during training, - by default 1. + Defaults to 1. save_interval : int, optional - The model will be saved every ``eval_interval`` loop during training, by - default None. + The model will be saved every ``eval_interval`` loop during training. + Defaults to None. save_dir : str, optional - Directory to save the model, by default None. + Directory to save the model. Defaults to None. """ data_examples = self.data_preprocess("train", train_data) diff --git a/ablkit/data/evaluation/base_metric.py b/ablkit/data/evaluation/base_metric.py index 9edf4d8..9cb0c44 100644 --- a/ablkit/data/evaluation/base_metric.py +++ b/ablkit/data/evaluation/base_metric.py @@ -24,7 +24,7 @@ class BaseMetric(metaclass=ABCMeta): prefix : str, optional The prefix that will be added in the metrics names to disambiguate homonymous metrics of different tasks. If prefix is not provided in the argument, - self.default_prefix will be used instead. Default to None. + self.default_prefix will be used instead. Defaults to None. """ diff --git a/ablkit/data/evaluation/reasoning_metric.py b/ablkit/data/evaluation/reasoning_metric.py index 63d66ea..37087b9 100644 --- a/ablkit/data/evaluation/reasoning_metric.py +++ b/ablkit/data/evaluation/reasoning_metric.py @@ -25,10 +25,10 @@ class ReasoningMetric(BaseMetric): ---------- kb : KBBase An instance of a knowledge base, used for logical reasoning and validation. - If not provided, reasoning checks are not performed. Default to None. + If not provided, reasoning checks are not performed. Defaults to None. prefix : str, optional The prefix that will be added to the metrics names to disambiguate homonymous - metrics of different tasks. Inherits from BaseMetric. Default to None. + metrics of different tasks. Inherits from BaseMetric. Defaults to None. Notes ----- diff --git a/ablkit/data/evaluation/symbol_accuracy.py b/ablkit/data/evaluation/symbol_accuracy.py index 3c2fa01..896d5b5 100644 --- a/ablkit/data/evaluation/symbol_accuracy.py +++ b/ablkit/data/evaluation/symbol_accuracy.py @@ -21,7 +21,7 @@ class SymbolAccuracy(BaseMetric): ---------- prefix : str, optional The prefix that will be added to the metrics names to disambiguate homonymous - metrics of different tasks. Inherits from BaseMetric. Default to None. + metrics of different tasks. Inherits from BaseMetric. Defaults to None. """ def process(self, data_examples: ListData) -> None: diff --git a/ablkit/learning/basic_nn.py b/ablkit/learning/basic_nn.py index 8782b1d..5a0b33b 100644 --- a/ablkit/learning/basic_nn.py +++ b/ablkit/learning/basic_nn.py @@ -33,30 +33,30 @@ class BasicNN: scheduler : Callable[..., Any], optional The learning rate scheduler used for training, which will be called at the end of each run of the ``fit`` method. It should implement the - ``step`` method, by default None. + ``step`` method. Defaults to None. device : Union[torch.device, str] The device on which the model will be trained or used for prediction, - by default torch.device("cpu"). + Defaults to torch.device("cpu"). batch_size : int, optional - The batch size used for training, by default 32. + The batch size used for training. Defaults to 32. num_epochs : int, optional - The number of epochs used for training, by default 1. + The number of epochs used for training. Defaults to 1. stop_loss : float, optional - The loss value at which to stop training, by default 0.0001. + The loss value at which to stop training. Defaults to 0.0001. num_workers : int - The number of workers used for loading data, by default 0. + The number of workers used for loading data. Defaults to 0. save_interval : int, optional - The model will be saved every ``save_interval`` epoch during training, by default None. + The model will be saved every ``save_interval`` epoch during training. Defaults to None. save_dir : str, optional - The directory in which to save the model during training, by default None. + The directory in which to save the model during training. Defaults to None. train_transform : Callable[..., Any], optional A function/transform that takes an object and returns a transformed version used - in the ``fit`` and ``train_epoch`` methods, by default None. + in the ``fit`` and ``train_epoch`` methods. Defaults to None. test_transform : Callable[..., Any], optional A function/transform that takes an object and returns a transformed version in the - ``predict``, ``predict_proba`` and ``score`` methods, , by default None. + ``predict``, ``predict_proba`` and ``score`` methods, . Defaults to None. collate_fn : Callable[[List[T]], Any], optional - The function used to collate data, by default None. + The function used to collate data. Defaults to None. """ def __init__( @@ -184,11 +184,11 @@ class BasicNN: Parameters ---------- data_loader : DataLoader, optional - The data loader used for training, by default None. + The data loader used for training. Defaults to None. X : List[Any], optional - The input data, by default None. + The input data. Defaults to None. y : List[int], optional - The target data, by default None. + The target data. Defaults to None. Returns ------- @@ -291,9 +291,9 @@ class BasicNN: Parameters ---------- data_loader : DataLoader, optional - The data loader used for prediction, by default None. + The data loader used for prediction. Defaults to None. X : List[Any], optional - The input data, by default None. + The input data. Defaults to None. Returns ------- @@ -333,9 +333,9 @@ class BasicNN: Parameters ---------- data_loader : DataLoader, optional - The data loader used for prediction, by default None. + The data loader used for prediction. Defaults to None. X : List[Any], optional - The input data, by default None. + The input data. Defaults to None. Returns ------- @@ -423,11 +423,11 @@ class BasicNN: Parameters ---------- data_loader : DataLoader, optional - The data loader used for scoring, by default None. + The data loader used for scoring. Defaults to None. X : List[Any], optional - The input data, by default None. + The input data. Defaults to None. y : List[int], optional - The target data, by default None. + The target data. Defaults to None. Returns ------- @@ -466,9 +466,9 @@ class BasicNN: X : List[Any] Input samples. y : List[int], optional - Target labels. If None, dummy labels are created, by default None. + Target labels. If None, dummy labels are created. Defaults to None. shuffle : bool, optional - Whether to shuffle the data, by default True. + Whether to shuffle the data. Defaults to True. Returns ------- @@ -507,7 +507,7 @@ class BasicNN: epoch_id : int The epoch id. save_path : str, optional - The path to save the model, by default None. + The path to save the model. Defaults to None. """ if self.save_dir is None and save_path is None: raise ValueError("'save_dir' and 'save_path' should not be None simultaneously.") @@ -536,7 +536,7 @@ class BasicNN: Parameters ---------- load_path : str - The directory to load the model, by default "". + The directory to load the model. Defaults to "". """ if load_path is None: diff --git a/ablkit/learning/model_converter.py b/ablkit/learning/model_converter.py index a9666a3..e217dc7 100644 --- a/ablkit/learning/model_converter.py +++ b/ablkit/learning/model_converter.py @@ -50,30 +50,30 @@ class ModelConverter: The dict contains necessary parameters to construct a learning rate scheduler used for training, which will be called at the end of each run of the ``fit`` method. The scheduler class is specified by the ``scheduler`` key. It should implement the - ``step`` method, by default None. + ``step`` method. Defaults to None. device : torch.device, optional The device on which the model will be trained or used for prediction, - by default torch.device("cpu"). + Defaults to torch.device("cpu"). batch_size : int, optional - The batch size used for training, by default 32. + The batch size used for training. Defaults to 32. num_epochs : int, optional - The number of epochs used for training, by default 1. + The number of epochs used for training. Defaults to 1. stop_loss : float, optional - The loss value at which to stop training, by default 0.0001. + The loss value at which to stop training. Defaults to 0.0001. num_workers : int - The number of workers used for loading data, by default 0. + The number of workers used for loading data. Defaults to 0. save_interval : int, optional - The model will be saved every ``save_interval`` epoch during training, by default None. + The model will be saved every ``save_interval`` epoch during training. Defaults to None. save_dir : str, optional - The directory in which to save the model during training, by default None. + The directory in which to save the model during training. Defaults to None. train_transform : Callable[..., Any], optional A function/transform that takes an object and returns a transformed version used - in the `fit` and `train_epoch` methods, by default None. + in the `fit` and `train_epoch` methods. Defaults to None. test_transform : Callable[..., Any], optional A function/transform that takes an object and returns a transformed version in the - `predict`, `predict_proba` and `score` methods, , by default None. + `predict`, `predict_proba` and `score` methods, . Defaults to None. collate_fn : Callable[[List[T]], Any], optional - The function used to collate data, by default None. + The function used to collate data. Defaults to None. Returns ------- @@ -140,30 +140,30 @@ class ModelConverter: The dict contains necessary parameters to construct a learning rate scheduler used for training, which will be called at the end of each run of the ``fit`` method. The scheduler class is specified by the ``scheduler`` key. It should implement the - ``step`` method, by default None. + ``step`` method. Defaults to None. device : torch.device, optional The device on which the model will be trained or used for prediction, - by default torch.device("cpu"). + Defaults to torch.device("cpu"). batch_size : int, optional - The batch size used for training, by default 32. + The batch size used for training. Defaults to 32. num_epochs : int, optional - The number of epochs used for training, by default 1. + The number of epochs used for training. Defaults to 1. stop_loss : float, optional - The loss value at which to stop training, by default 0.0001. + The loss value at which to stop training. Defaults to 0.0001. num_workers : int - The number of workers used for loading data, by default 0. + The number of workers used for loading data. Defaults to 0. save_interval : int, optional - The model will be saved every ``save_interval`` epoch during training, by default None. + The model will be saved every ``save_interval`` epoch during training. Defaults to None. save_dir : str, optional - The directory in which to save the model during training, by default None. + The directory in which to save the model during training. Defaults to None. train_transform : Callable[..., Any], optional A function/transform that takes an object and returns a transformed version used - in the `fit` and `train_epoch` methods, by default None. + in the `fit` and `train_epoch` methods. Defaults to None. test_transform : Callable[..., Any], optional A function/transform that takes an object and returns a transformed version in the - `predict`, `predict_proba` and `score` methods, , by default None. + `predict`, `predict_proba` and `score` methods, . Defaults to None. collate_fn : Callable[[List[T]], Any], optional - The function used to collate data, by default None. + The function used to collate data. Defaults to None. Returns ------- diff --git a/ablkit/utils/logger.py b/ablkit/utils/logger.py index 2f234ce..dd069b5 100644 --- a/ablkit/utils/logger.py +++ b/ablkit/utils/logger.py @@ -26,7 +26,7 @@ class FilterDuplicateWarning(logging.Filter): Parameters ---------- name : str, optional - The name of the filter, by default "abl". + The name of the filter. Defaults to "abl". """ def __init__(self, name: Optional[str] = "abl"): diff --git a/ablkit/utils/utils.py b/ablkit/utils/utils.py index efa2bf2..abc1e35 100644 --- a/ablkit/utils/utils.py +++ b/ablkit/utils/utils.py @@ -193,7 +193,7 @@ def tab_data_to_tuple( y : Union[List[Any], Any] The label. reasoning_result : Any, optional - The reasoning result, by default 0. + The reasoning result. Defaults to 0. Returns -------