@@ -113,7 +113,7 @@ To facilitate uniform processing, ABL Kit provides the `BasicNN` class to conver | |||||
```python | ```python | ||||
import torch | import torch | ||||
from abl.learning import BasicNN | |||||
from ablkit.learning import BasicNN | |||||
| | ||||
loss_fn = torch.nn.CrossEntropyLoss() | loss_fn = torch.nn.CrossEntropyLoss() | ||||
optimizer = torch.optim.RMSprop(cls.parameters(), lr=0.001, alpha=0.9) | optimizer = torch.optim.RMSprop(cls.parameters(), lr=0.001, alpha=0.9) | ||||
@@ -124,7 +124,7 @@ To facilitate uniform processing, ABL Kit provides the `BasicNN` class to conver | |||||
The base model built above is trained to make predictions on instance-level data (e.g., a single image), while ABL deals with example-level data. To bridge this gap, we wrap the base_model into an instance of `ABLModel`. This class serves as a unified wrapper for base models, facilitating the learning part to train, test, and predict on example-level data, (e.g., images that comprise an equation). | The base model built above is trained to make predictions on instance-level data (e.g., a single image), while ABL deals with example-level data. To bridge this gap, we wrap the base_model into an instance of `ABLModel`. This class serves as a unified wrapper for base models, facilitating the learning part to train, test, and predict on example-level data, (e.g., images that comprise an equation). | ||||
```python | ```python | ||||
from abl.learning import ABLModel | |||||
from ablkit.learning import ABLModel | |||||
| | ||||
model = ABLModel(base_model) | model = ABLModel(base_model) | ||||
``` | ``` | ||||
@@ -138,7 +138,7 @@ from abl.learning import ABLModel | |||||
To build the reasoning part, we first define a knowledge base by creating a subclass of `KBBase`. In the subclass, we initialize the `pseudo_label_list` parameter and override the `logic_forward` method, which specifies how to perform (deductive) reasoning that processes pseudo-labels of an example to the corresponding reasoning result. Specifically, for the MNIST Addition task, this `logic_forward` method is tailored to execute the sum operation. | To build the reasoning part, we first define a knowledge base by creating a subclass of `KBBase`. In the subclass, we initialize the `pseudo_label_list` parameter and override the `logic_forward` method, which specifies how to perform (deductive) reasoning that processes pseudo-labels of an example to the corresponding reasoning result. Specifically, for the MNIST Addition task, this `logic_forward` method is tailored to execute the sum operation. | ||||
```python | ```python | ||||
from abl.reasoning import KBBase | |||||
from ablkit.reasoning import KBBase | |||||
| | ||||
class AddKB(KBBase): | class AddKB(KBBase): | ||||
def __init__(self, pseudo_label_list=list(range(10))): | def __init__(self, pseudo_label_list=list(range(10))): | ||||
@@ -153,7 +153,7 @@ kb = AddKB() | |||||
Next, we create a reasoner by instantiating the class `Reasoner`, passing the knowledge base as a parameter. Due to the indeterminism of abductive reasoning, there could be multiple candidate pseudo-labels compatible to the knowledge base. In such scenarios, the reasoner can minimize inconsistency and return the pseudo-label with the highest consistency. | Next, we create a reasoner by instantiating the class `Reasoner`, passing the knowledge base as a parameter. Due to the indeterminism of abductive reasoning, there could be multiple candidate pseudo-labels compatible to the knowledge base. In such scenarios, the reasoner can minimize inconsistency and return the pseudo-label with the highest consistency. | ||||
```python | ```python | ||||
from abl.reasoning import Reasoner | |||||
from ablkit.reasoning import Reasoner | |||||
| | ||||
reasoner = Reasoner(kb) | reasoner = Reasoner(kb) | ||||
``` | ``` | ||||
@@ -167,7 +167,7 @@ reasoner = Reasoner(kb) | |||||
ABL Kit provides two basic metrics, namely `SymbolAccuracy` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model's predictions and the accuracy of the `logic_forward` results, respectively. | ABL Kit provides two basic metrics, namely `SymbolAccuracy` and `ReasoningMetric`, which are used to evaluate the accuracy of the machine learning model's predictions and the accuracy of the `logic_forward` results, respectively. | ||||
```python | ```python | ||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
| | ||||
metric_list = [SymbolAccuracy(), ReasoningMetric(kb=kb)] | metric_list = [SymbolAccuracy(), ReasoningMetric(kb=kb)] | ||||
``` | ``` | ||||
@@ -182,7 +182,7 @@ Now, we use `SimpleBridge` to combine learning and reasoning in a | |||||
unified ABL framework. | unified ABL framework. | ||||
```python | ```python | ||||
from abl.bridge import SimpleBridge | |||||
from ablkit.bridge import SimpleBridge | |||||
| | ||||
bridge = SimpleBridge(model, reasoner, metric_list) | bridge = SimpleBridge(model, reasoner, metric_list) | ||||
``` | ``` | ||||
@@ -1,6 +1,6 @@ | |||||
from typing import Any, Tuple | from typing import Any, Tuple | ||||
from abl.utils import tab_data_to_tuple | |||||
from ablkit.utils import tab_data_to_tuple | |||||
from .structures.list_data import ListData | from .structures.list_data import ListData | ||||
from lambdaLearn.Base.TabularMixin import TabularMixin | from lambdaLearn.Base.TabularMixin import TabularMixin | ||||
@@ -57,7 +57,7 @@ class ListData(BaseDataElement): | |||||
class implemented in `MMEngine <https://github.com/open-mmlab/mmengine/blob/main/mmengine/structures/base_data_element.py>`_. # noqa: E501 | class implemented in `MMEngine <https://github.com/open-mmlab/mmengine/blob/main/mmengine/structures/base_data_element.py>`_. # noqa: E501 | ||||
Examples: | Examples: | ||||
>>> from abl.data.structures import ListData | |||||
>>> from ablkit.data.structures import ListData | |||||
>>> import numpy as np | >>> import numpy as np | ||||
>>> import torch | >>> import torch | ||||
>>> data_examples = ListData() | >>> data_examples = ListData() |
@@ -1,7 +1,7 @@ | |||||
abl.bridge | |||||
ablkit.bridge | |||||
================== | ================== | ||||
.. automodule:: abl.bridge | |||||
.. automodule:: ablkit.bridge | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: |
@@ -1,10 +1,10 @@ | |||||
abl.data | |||||
ablkit.data | |||||
=================== | =================== | ||||
``structures`` | ``structures`` | ||||
-------------- | -------------- | ||||
.. autoclass:: abl.data.structures.ListData | |||||
.. autoclass:: ablkit.data.structures.ListData | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: | ||||
@@ -12,7 +12,7 @@ abl.data | |||||
``evaluation`` | ``evaluation`` | ||||
-------------- | -------------- | ||||
.. automodule:: abl.data.evaluation | |||||
.. automodule:: ablkit.data.evaluation | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: |
@@ -1,12 +1,12 @@ | |||||
abl.learning | |||||
ablkit.learning | |||||
================== | ================== | ||||
.. autoclass:: abl.learning.ABLModel | |||||
.. autoclass:: ablkit.learning.ABLModel | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: | ||||
.. autoclass:: abl.learning.BasicNN | |||||
.. autoclass:: ablkit.learning.BasicNN | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: | ||||
@@ -14,7 +14,7 @@ abl.learning | |||||
``torch_dataset`` | ``torch_dataset`` | ||||
----------------- | ----------------- | ||||
.. automodule:: abl.learning.torch_dataset | |||||
.. automodule:: ablkit.learning.torch_dataset | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: |
@@ -1,7 +1,7 @@ | |||||
abl.reasoning | |||||
ablkit.reasoning | |||||
================== | ================== | ||||
.. automodule:: abl.reasoning | |||||
.. automodule:: ablkit.reasoning | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: |
@@ -1,7 +1,7 @@ | |||||
abl.utils | |||||
ablkit.utils | |||||
================== | ================== | ||||
.. automodule:: abl.utils | |||||
.. automodule:: ablkit.utils | |||||
:members: | :members: | ||||
:undoc-members: | :undoc-members: | ||||
:show-inheritance: | :show-inheritance: |
@@ -34,8 +34,8 @@ model. | |||||
import torch | import torch | ||||
import torch.nn as nn | import torch.nn as nn | ||||
from abl.learning import ABLModel, BasicNN | |||||
from abl.utils import ABLLogger, print_log | |||||
from ablkit.learning import ABLModel, BasicNN | |||||
from ablkit.utils import ABLLogger, print_log | |||||
from bridge import HedBridge | from bridge import HedBridge | ||||
from consistency_metric import ConsistencyMetric | from consistency_metric import ConsistencyMetric | ||||
@@ -32,11 +32,11 @@ machine learning model. | |||||
import torch | import torch | ||||
import torch.nn as nn | import torch.nn as nn | ||||
from abl.bridge import SimpleBridge | |||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from abl.learning import ABLModel, BasicNN | |||||
from abl.reasoning import KBBase, Reasoner | |||||
from abl.utils import ABLLogger, print_log | |||||
from ablkit.bridge import SimpleBridge | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.learning import ABLModel, BasicNN | |||||
from ablkit.reasoning import KBBase, Reasoner | |||||
from ablkit.utils import ABLLogger, print_log | |||||
from datasets import get_dataset | from datasets import get_dataset | ||||
from models.nn import SymbolNet | from models.nn import SymbolNet | ||||
@@ -232,7 +232,7 @@ examples. | |||||
.. code:: ipython3 | .. code:: ipython3 | ||||
from abl.data.structures import ListData | |||||
from ablkit.data.structures import ListData | |||||
# ListData is a data structure provided by ABL Kit that can be used to organize data examples | # ListData is a data structure provided by ABL Kit that can be used to organize data examples | ||||
data_examples = ListData() | data_examples = ListData() | ||||
# We use the first 1001st and 3001st data examples in the training set as an illustration | # We use the first 1001st and 3001st data examples in the training set as an illustration | ||||
@@ -31,11 +31,11 @@ machine learning model. | |||||
import torch.nn as nn | import torch.nn as nn | ||||
from torch.optim import RMSprop, lr_scheduler | from torch.optim import RMSprop, lr_scheduler | ||||
from abl.bridge import SimpleBridge | |||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from abl.learning import ABLModel, BasicNN | |||||
from abl.reasoning import KBBase, Reasoner | |||||
from abl.utils import ABLLogger, print_log | |||||
from ablkit.bridge import SimpleBridge | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.learning import ABLModel, BasicNN | |||||
from ablkit.reasoning import KBBase, Reasoner | |||||
from ablkit.utils import ABLLogger, print_log | |||||
from datasets import get_dataset | from datasets import get_dataset | ||||
from models.nn import LeNet5 | from models.nn import LeNet5 | ||||
@@ -202,7 +202,7 @@ examples. | |||||
.. code:: ipython3 | .. code:: ipython3 | ||||
from abl.data.structures import ListData | |||||
from ablkit.data.structures import ListData | |||||
# ListData is a data structure provided by ABL Kit that can be used to organize data examples | # ListData is a data structure provided by ABL Kit that can be used to organize data examples | ||||
data_examples = ListData() | data_examples = ListData() | ||||
# We use the first 100 data examples in the training set as an illustration | # We use the first 100 data examples in the training set as an illustration | ||||
@@ -28,11 +28,11 @@ further update the learning model. | |||||
import numpy as np | import numpy as np | ||||
from sklearn.ensemble import RandomForestClassifier | from sklearn.ensemble import RandomForestClassifier | ||||
from abl.bridge import SimpleBridge | |||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from abl.learning import ABLModel | |||||
from abl.reasoning import Reasoner | |||||
from abl.utils import ABLLogger, confidence_dist, print_log, tab_data_to_tuple | |||||
from ablkit.bridge import SimpleBridge | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.learning import ABLModel | |||||
from ablkit.reasoning import Reasoner | |||||
from ablkit.utils import ABLLogger, confidence_dist, print_log, tab_data_to_tuple | |||||
from get_dataset import load_and_preprocess_dataset, split_dataset | from get_dataset import load_and_preprocess_dataset, split_dataset | ||||
from kb import ZooKB | from kb import ZooKB | ||||
@@ -14,7 +14,7 @@ In this section, we will look at how to bridge learning and reasoning parts to t | |||||
.. code:: python | .. code:: python | ||||
from abl.bridge import BaseBridge, SimpleBridge | |||||
from ablkit.bridge import BaseBridge, SimpleBridge | |||||
``BaseBridge`` is an abstract class with the following initialization parameters: | ``BaseBridge`` is an abstract class with the following initialization parameters: | ||||
@@ -42,7 +42,7 @@ In this section, we will look at how to bridge learning and reasoning parts to t | |||||
| ``test(test_data)`` | Test the model. | | | ``test(test_data)`` | Test the model. | | ||||
+---------------------------------------+----------------------------------------------------+ | +---------------------------------------+----------------------------------------------------+ | ||||
where ``train_data`` and ``test_data`` are both in the form of a tuple or a `ListData <../API/abl.data.html#structures.ListData>`_. Regardless of the form, they all need to include three components: ``X``, ``gt_pseudo_label`` and ``Y``. Since ``ListData`` is the underlying data structure used throughout the ABL Kit, tuple-formed data will be firstly transformed into ``ListData`` in the ``train`` and ``test`` methods, and such ``ListData`` instances are referred to as ``data_examples``. More details can be found in `preparing datasets <Datasets.html>`_. | |||||
where ``train_data`` and ``test_data`` are both in the form of a tuple or a `ListData <../API/ablkit.data.html#structures.ListData>`_. Regardless of the form, they all need to include three components: ``X``, ``gt_pseudo_label`` and ``Y``. Since ``ListData`` is the underlying data structure used throughout the ABL Kit, tuple-formed data will be firstly transformed into ``ListData`` in the ``train`` and ``test`` methods, and such ``ListData`` instances are referred to as ``data_examples``. More details can be found in `preparing datasets <Datasets.html>`_. | |||||
``SimpleBridge`` inherits from ``BaseBridge`` and provides a basic implementation. Besides the ``model`` and ``reasoner``, ``SimpleBridge`` has an extra initialization argument, ``metric_list``, which will be used to evaluate model performance. Its training process involves several Abductive Learning loops and each loop consists of the following five steps: | ``SimpleBridge`` inherits from ``BaseBridge`` and provides a basic implementation. Besides the ``model`` and ``reasoner``, ``SimpleBridge`` has an extra initialization argument, ``metric_list``, which will be used to evaluate model performance. Its training process involves several Abductive Learning loops and each loop consists of the following five steps: | ||||
@@ -15,7 +15,7 @@ In this section, we will look at the dataset and data structure in ABL Kit. | |||||
.. code:: python | .. code:: python | ||||
import torch | import torch | ||||
from abl.data.structures import ListData | |||||
from ablkit.data.structures import ListData | |||||
Dataset | Dataset | ||||
------- | ------- | ||||
@@ -62,11 +62,11 @@ where each sublist in ``X``, e.g., |data_example|, is a data example and each im | |||||
Data Structure | Data Structure | ||||
-------------- | -------------- | ||||
Besides the user-provided dataset, various forms of data are utilized and dynamicly generated throughout the training and testing process of ABL framework. Examples include raw data, predicted pseudo-label, abduced pseudo-label, pseudo-label indices, etc. To manage this diversity and ensure a stable, versatile interface, ABL Kit employs `abstract data interfaces <../API/abl.data.html#structure>`_ to encapsulate different forms of data that will be used in the total learning process. | |||||
Besides the user-provided dataset, various forms of data are utilized and dynamicly generated throughout the training and testing process of ABL framework. Examples include raw data, predicted pseudo-label, abduced pseudo-label, pseudo-label indices, etc. To manage this diversity and ensure a stable, versatile interface, ABL Kit employs `abstract data interfaces <../API/ablkit.data.html#structure>`_ to encapsulate different forms of data that will be used in the total learning process. | |||||
``ListData`` is the underlying abstract data interface utilized in ABL Kit. As the fundamental data structure, ``ListData`` implements commonly used data manipulation methods and is responsible for transferring data between various components of ABL, ensuring that stages such as prediction, abductive reasoning, and training can utilize ``ListData`` as a unified input format. Before proceeding to other stages, user-provided datasets will be firstly converted into ``ListData``. | ``ListData`` is the underlying abstract data interface utilized in ABL Kit. As the fundamental data structure, ``ListData`` implements commonly used data manipulation methods and is responsible for transferring data between various components of ABL, ensuring that stages such as prediction, abductive reasoning, and training can utilize ``ListData`` as a unified input format. Before proceeding to other stages, user-provided datasets will be firstly converted into ``ListData``. | ||||
Besides providing a tuple of ``(X, gt_pseudo_label, Y)``, ABL Kit also allows users to directly supply data in ``ListData`` format, which similarly requires the inclusion of these three attributes. The following code shows the basic usage of ``ListData``. More information can be found in the `API documentation <../API/abl.data.html#structure>`_. | |||||
Besides providing a tuple of ``(X, gt_pseudo_label, Y)``, ABL Kit also allows users to directly supply data in ``ListData`` format, which similarly requires the inclusion of these three attributes. The following code shows the basic usage of ``ListData``. More information can be found in the `API documentation <../API/ablkit.data.html#structure>`_. | |||||
.. code-block:: python | .. code-block:: python | ||||
@@ -14,7 +14,7 @@ In this section, we will look at how to build evaluation metrics. | |||||
.. code:: python | .. code:: python | ||||
from abl.data.evaluation import BaseMetric, SymbolAccuracy, ReasoningMetric | |||||
from ablkit.data.evaluation import BaseMetric, SymbolAccuracy, ReasoningMetric | |||||
ABL Kit seperates the evaluation process from model training and testing as an independent class, ``BaseMetric``. The training and testing processes are implemented in the ``BaseBridge`` class, so metrics are used by this class and its sub-classes. After building a ``bridge`` with a list of ``BaseMetric`` instances, these metrics will be used by the ``bridge.valid`` method to evaluate the model performance during training and testing. | ABL Kit seperates the evaluation process from model training and testing as an independent class, ``BaseMetric``. The training and testing processes are implemented in the ``BaseBridge`` class, so metrics are used by this class and its sub-classes. After building a ``bridge`` with a list of ``BaseMetric`` instances, these metrics will be used by the ``bridge.valid`` method to evaluate the model performance during training and testing. | ||||
@@ -21,7 +21,7 @@ In ABL Kit, building the learning part involves two steps: | |||||
import sklearn | import sklearn | ||||
import torchvision | import torchvision | ||||
from abl.learning import BasicNN, ABLModel | |||||
from ablkit.learning import BasicNN, ABLModel | |||||
Building a base model | Building a base model | ||||
--------------------- | --------------------- | ||||
@@ -48,7 +48,7 @@ To facilitate uniform processing, ABL Kit provides the ``BasicNN`` class to conv | |||||
.. code:: python | .. code:: python | ||||
import torch | import torch | ||||
from abl.learning import BasicNN | |||||
from ablkit.learning import BasicNN | |||||
loss_fn = torch.nn.CrossEntropyLoss() | loss_fn = torch.nn.CrossEntropyLoss() | ||||
optimizer = torch.optim.RMSprop(cls.parameters(), lr=0.001) | optimizer = torch.optim.RMSprop(cls.parameters(), lr=0.001) | ||||
@@ -59,7 +59,7 @@ The base model built above is trained to make predictions on instance-level data | |||||
.. code:: python | .. code:: python | ||||
from abl.learning import ABLModel | |||||
from ablkit.learning import ABLModel | |||||
model = ABLModel(base_model) | model = ABLModel(base_model) | ||||
@@ -72,7 +72,7 @@ To build the reasoning part, we first define a knowledge base by creating a subc | |||||
.. code:: python | .. code:: python | ||||
from abl.reasoning import KBBase | |||||
from ablkit.reasoning import KBBase | |||||
class AddKB(KBBase): | class AddKB(KBBase): | ||||
def __init__(self, pseudo_label_list=list(range(10))): | def __init__(self, pseudo_label_list=list(range(10))): | ||||
@@ -89,7 +89,7 @@ In such scenarios, the reasoner can minimize inconsistency and return the pseudo | |||||
.. code:: python | .. code:: python | ||||
from abl.reasoning import Reasoner | |||||
from ablkit.reasoning import Reasoner | |||||
reasoner = Reasoner(kb) | reasoner = Reasoner(kb) | ||||
@@ -102,7 +102,7 @@ ABL Kit provides two basic metrics, namely ``SymbolAccuracy`` and ``ReasoningMet | |||||
.. code:: python | .. code:: python | ||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
metric_list = [SymbolAccuracy(), ReasoningMetric(kb=kb)] | metric_list = [SymbolAccuracy(), ReasoningMetric(kb=kb)] | ||||
@@ -115,7 +115,7 @@ Now, we use ``SimpleBridge`` to combine learning and reasoning in a unified ABL | |||||
.. code:: python | .. code:: python | ||||
from abl.bridge import SimpleBridge | |||||
from ablkit.bridge import SimpleBridge | |||||
bridge = SimpleBridge(model, reasoner, metric_list) | bridge = SimpleBridge(model, reasoner, metric_list) | ||||
@@ -22,7 +22,7 @@ In ABL Kit, building the reasoning part involves two steps: | |||||
.. code:: python | .. code:: python | ||||
from abl.reasoning import KBBase, GroundKB, PrologKB, Reasoner | |||||
from ablkit.reasoning import KBBase, GroundKB, PrologKB, Reasoner | |||||
Building a knowledge base | Building a knowledge base | ||||
------------------------- | ------------------------- | ||||
@@ -32,11 +32,11 @@ | |||||
:maxdepth: 1 | :maxdepth: 1 | ||||
:caption: API | :caption: API | ||||
API/abl.data | |||||
API/abl.learning | |||||
API/abl.reasoning | |||||
API/abl.bridge | |||||
API/abl.utils | |||||
API/ablkit.data | |||||
API/ablkit.learning | |||||
API/ablkit.reasoning | |||||
API/ablkit.bridge | |||||
API/ablkit.utils | |||||
.. toctree:: | .. toctree:: | ||||
:maxdepth: 1 | :maxdepth: 1 | ||||
@@ -4,13 +4,13 @@ from typing import Any, List, Optional, Tuple, Union | |||||
import torch | import torch | ||||
from abl.bridge import SimpleBridge | |||||
from abl.data.evaluation import BaseMetric | |||||
from abl.data.structures import ListData | |||||
from abl.learning import ABLModel, BasicNN | |||||
from abl.learning.torch_dataset import RegressionDataset | |||||
from abl.reasoning import Reasoner | |||||
from abl.utils import print_log | |||||
from ablkit.bridge import SimpleBridge | |||||
from ablkit.data.evaluation import BaseMetric | |||||
from ablkit.data.structures import ListData | |||||
from ablkit.learning import ABLModel, BasicNN | |||||
from ablkit.learning.torch_dataset import RegressionDataset | |||||
from ablkit.reasoning import Reasoner | |||||
from ablkit.utils import print_log | |||||
from datasets import get_pretrain_data | from datasets import get_pretrain_data | ||||
from models.nn import SymbolNetAutoencoder | from models.nn import SymbolNetAutoencoder | ||||
@@ -1,8 +1,8 @@ | |||||
from typing import Optional | from typing import Optional | ||||
from abl.data.evaluation.base_metric import BaseMetric | |||||
from abl.data.structures import ListData | |||||
from abl.reasoning import KBBase | |||||
from ablkit.data.evaluation.base_metric import BaseMetric | |||||
from ablkit.data.structures import ListData | |||||
from ablkit.reasoning import KBBase | |||||
class ConsistencyMetric(BaseMetric): | class ConsistencyMetric(BaseMetric): | ||||
@@ -24,8 +24,8 @@ | |||||
"import torch\n", | "import torch\n", | ||||
"import torch.nn as nn\n", | "import torch.nn as nn\n", | ||||
"\n", | "\n", | ||||
"from abl.learning import ABLModel, BasicNN\n", | |||||
"from abl.utils import ABLLogger, print_log\n", | |||||
"from ablkit.learning import ABLModel, BasicNN\n", | |||||
"from ablkit.utils import ABLLogger, print_log\n", | |||||
"\n", | "\n", | ||||
"from bridge import HedBridge\n", | "from bridge import HedBridge\n", | ||||
"from consistency_metric import ConsistencyMetric\n", | "from consistency_metric import ConsistencyMetric\n", | ||||
@@ -4,8 +4,8 @@ import os.path as osp | |||||
import torch | import torch | ||||
import torch.nn as nn | import torch.nn as nn | ||||
from abl.learning import ABLModel, BasicNN | |||||
from abl.utils import ABLLogger, print_log | |||||
from ablkit.learning import ABLModel, BasicNN | |||||
from ablkit.utils import ABLLogger, print_log | |||||
from bridge import HedBridge | from bridge import HedBridge | ||||
from consistency_metric import ConsistencyMetric | from consistency_metric import ConsistencyMetric | ||||
@@ -3,8 +3,8 @@ import os | |||||
import numpy as np | import numpy as np | ||||
from abl.reasoning import PrologKB, Reasoner | |||||
from abl.utils import reform_list | |||||
from ablkit.reasoning import PrologKB, Reasoner | |||||
from ablkit.utils import reform_list | |||||
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) | CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) | ||||
@@ -25,11 +25,11 @@ | |||||
"import torch\n", | "import torch\n", | ||||
"import torch.nn as nn\n", | "import torch.nn as nn\n", | ||||
"\n", | "\n", | ||||
"from abl.bridge import SimpleBridge\n", | |||||
"from abl.data.evaluation import ReasoningMetric, SymbolAccuracy\n", | |||||
"from abl.learning import ABLModel, BasicNN\n", | |||||
"from abl.reasoning import KBBase, Reasoner\n", | |||||
"from abl.utils import ABLLogger, print_log\n", | |||||
"from ablkit.bridge import SimpleBridge\n", | |||||
"from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy\n", | |||||
"from ablkit.learning import ABLModel, BasicNN\n", | |||||
"from ablkit.reasoning import KBBase, Reasoner\n", | |||||
"from ablkit.utils import ABLLogger, print_log\n", | |||||
"\n", | "\n", | ||||
"from datasets import get_dataset\n", | "from datasets import get_dataset\n", | ||||
"from models.nn import SymbolNet" | "from models.nn import SymbolNet" | ||||
@@ -235,7 +235,7 @@ | |||||
"metadata": {}, | "metadata": {}, | ||||
"outputs": [], | "outputs": [], | ||||
"source": [ | "source": [ | ||||
"from abl.data.structures import ListData\n", | |||||
"from ablkit.data.structures import ListData\n", | |||||
"\n", | "\n", | ||||
"# ListData is a data structure provided by ABL Kit that can be used to organize data examples\n", | "# ListData is a data structure provided by ABL Kit that can be used to organize data examples\n", | ||||
"data_examples = ListData()\n", | "data_examples = ListData()\n", | ||||
@@ -5,11 +5,11 @@ import numpy as np | |||||
import torch | import torch | ||||
from torch import nn | from torch import nn | ||||
from abl.bridge import SimpleBridge | |||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from abl.learning import ABLModel, BasicNN | |||||
from abl.reasoning import GroundKB, KBBase, Reasoner | |||||
from abl.utils import ABLLogger, print_log | |||||
from ablkit.bridge import SimpleBridge | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.learning import ABLModel, BasicNN | |||||
from ablkit.reasoning import GroundKB, KBBase, Reasoner | |||||
from ablkit.utils import ABLLogger, print_log | |||||
from datasets import get_dataset | from datasets import get_dataset | ||||
from models.nn import SymbolNet | from models.nn import SymbolNet | ||||
@@ -5,11 +5,11 @@ import torch | |||||
from torch import nn | from torch import nn | ||||
from torch.optim import RMSprop, lr_scheduler | from torch.optim import RMSprop, lr_scheduler | ||||
from abl.bridge import SimpleBridge | |||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from abl.learning import ABLModel, BasicNN | |||||
from abl.reasoning import GroundKB, KBBase, PrologKB, Reasoner | |||||
from abl.utils import ABLLogger, print_log | |||||
from ablkit.bridge import SimpleBridge | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.learning import ABLModel, BasicNN | |||||
from ablkit.reasoning import GroundKB, KBBase, PrologKB, Reasoner | |||||
from ablkit.utils import ABLLogger, print_log | |||||
from datasets import get_dataset | from datasets import get_dataset | ||||
from models.nn import LeNet5 | from models.nn import LeNet5 | ||||
@@ -25,11 +25,11 @@ | |||||
"import torch.nn as nn\n", | "import torch.nn as nn\n", | ||||
"from torch.optim import RMSprop, lr_scheduler\n", | "from torch.optim import RMSprop, lr_scheduler\n", | ||||
"\n", | "\n", | ||||
"from abl.bridge import SimpleBridge\n", | |||||
"from abl.data.evaluation import ReasoningMetric, SymbolAccuracy\n", | |||||
"from abl.learning import ABLModel, BasicNN\n", | |||||
"from abl.reasoning import KBBase, Reasoner\n", | |||||
"from abl.utils import ABLLogger, print_log\n", | |||||
"from ablkit.bridge import SimpleBridge\n", | |||||
"from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy\n", | |||||
"from ablkit.learning import ABLModel, BasicNN\n", | |||||
"from ablkit.reasoning import KBBase, Reasoner\n", | |||||
"from ablkit.utils import ABLLogger, print_log\n", | |||||
"\n", | "\n", | ||||
"from datasets import get_dataset\n", | "from datasets import get_dataset\n", | ||||
"from models.nn import LeNet5" | "from models.nn import LeNet5" | ||||
@@ -280,7 +280,7 @@ | |||||
} | } | ||||
], | ], | ||||
"source": [ | "source": [ | ||||
"from abl.data.structures import ListData\n", | |||||
"from ablkit.data.structures import ListData\n", | |||||
"\n", | "\n", | ||||
"# ListData is a data structure provided by ABL Kit that can be used to organize data examples\n", | "# ListData is a data structure provided by ABL Kit that can be used to organize data examples\n", | ||||
"data_examples = ListData()\n", | "data_examples = ListData()\n", | ||||
@@ -1,7 +1,7 @@ | |||||
import openml | import openml | ||||
from z3 import If, Implies, Int, Not, Solver, Sum, sat # noqa: F401 | from z3 import If, Implies, Int, Not, Solver, Sum, sat # noqa: F401 | ||||
from abl.reasoning import KBBase | |||||
from ablkit.reasoning import KBBase | |||||
class ZooKB(KBBase): | class ZooKB(KBBase): | ||||
@@ -4,11 +4,11 @@ import os.path as osp | |||||
import numpy as np | import numpy as np | ||||
from sklearn.ensemble import RandomForestClassifier | from sklearn.ensemble import RandomForestClassifier | ||||
from abl.bridge import SimpleBridge | |||||
from abl.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from abl.learning import ABLModel | |||||
from abl.reasoning import Reasoner | |||||
from abl.utils import ABLLogger, avg_confidence_dist, print_log, tab_data_to_tuple | |||||
from ablkit.bridge import SimpleBridge | |||||
from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy | |||||
from ablkit.learning import ABLModel | |||||
from ablkit.reasoning import Reasoner | |||||
from ablkit.utils import ABLLogger, avg_confidence_dist, print_log, tab_data_to_tuple | |||||
from get_dataset import load_and_preprocess_dataset, split_dataset | from get_dataset import load_and_preprocess_dataset, split_dataset | ||||
from kb import ZooKB | from kb import ZooKB | ||||
@@ -23,11 +23,11 @@ | |||||
"import numpy as np\n", | "import numpy as np\n", | ||||
"from sklearn.ensemble import RandomForestClassifier\n", | "from sklearn.ensemble import RandomForestClassifier\n", | ||||
"\n", | "\n", | ||||
"from abl.bridge import SimpleBridge\n", | |||||
"from abl.data.evaluation import ReasoningMetric, SymbolAccuracy\n", | |||||
"from abl.learning import ABLModel\n", | |||||
"from abl.reasoning import Reasoner\n", | |||||
"from abl.utils import ABLLogger, avg_confidence_dist, print_log, tab_data_to_tuple\n", | |||||
"from ablkit.bridge import SimpleBridge\n", | |||||
"from ablkit.data.evaluation import ReasoningMetric, SymbolAccuracy\n", | |||||
"from ablkit.learning import ABLModel\n", | |||||
"from ablkit.reasoning import Reasoner\n", | |||||
"from ablkit.utils import ABLLogger, avg_confidence_dist, print_log, tab_data_to_tuple\n", | |||||
"\n", | "\n", | ||||
"from get_dataset import load_and_preprocess_dataset, split_dataset\n", | "from get_dataset import load_and_preprocess_dataset, split_dataset\n", | ||||
"from kb import ZooKB" | "from kb import ZooKB" | ||||
@@ -5,9 +5,9 @@ import torch | |||||
import torch.nn as nn | import torch.nn as nn | ||||
import torch.optim as optim | import torch.optim as optim | ||||
from abl.data.structures import ListData | |||||
from abl.learning import BasicNN | |||||
from abl.reasoning import GroundKB, KBBase, PrologKB, Reasoner | |||||
from ablkit.data.structures import ListData | |||||
from ablkit.learning import BasicNN | |||||
from ablkit.reasoning import GroundKB, KBBase, PrologKB, Reasoner | |||||
class LeNet5(nn.Module): | class LeNet5(nn.Module): | ||||
@@ -3,7 +3,7 @@ from unittest.mock import Mock, create_autospec | |||||
import numpy as np | import numpy as np | ||||
import pytest | import pytest | ||||
from abl.learning import ABLModel | |||||
from ablkit.learning import ABLModel | |||||
class TestABLModel(object): | class TestABLModel(object): | ||||
@@ -2,7 +2,7 @@ import numpy as np | |||||
import platform | import platform | ||||
import pytest | import pytest | ||||
from abl.reasoning import PrologKB, Reasoner | |||||
from ablkit.reasoning import PrologKB, Reasoner | |||||
class TestKBBase(object): | class TestKBBase(object): | ||||