Browse Source

[FIX] unify docstring

pull/6/head
troyyyyy 1 year ago
parent
commit
00a4aa57d0
8 changed files with 60 additions and 60 deletions
  1. +7
    -7
      ablkit/bridge/simple_bridge.py
  2. +1
    -1
      ablkit/data/evaluation/base_metric.py
  3. +2
    -2
      ablkit/data/evaluation/reasoning_metric.py
  4. +1
    -1
      ablkit/data/evaluation/symbol_accuracy.py
  5. +25
    -25
      ablkit/learning/basic_nn.py
  6. +22
    -22
      ablkit/learning/model_converter.py
  7. +1
    -1
      ablkit/utils/logger.py
  8. +1
    -1
      ablkit/utils/utils.py

+ 7
- 7
ablkit/bridge/simple_bridge.py View File

@@ -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)



+ 1
- 1
ablkit/data/evaluation/base_metric.py View File

@@ -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.

"""



+ 2
- 2
ablkit/data/evaluation/reasoning_metric.py View File

@@ -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
-----


+ 1
- 1
ablkit/data/evaluation/symbol_accuracy.py View File

@@ -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:


+ 25
- 25
ablkit/learning/basic_nn.py View File

@@ -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:


+ 22
- 22
ablkit/learning/model_converter.py View File

@@ -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
-------


+ 1
- 1
ablkit/utils/logger.py View File

@@ -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"):


+ 1
- 1
ablkit/utils/utils.py View File

@@ -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
-------


Loading…
Cancel
Save