| @@ -3,7 +3,7 @@ Handwritten Equation Decipherment (HED) | |||
| .. raw:: html | |||
| <p>For detailed code implementation, please view on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/hed" target="_blank">GitHub</a>.</p> | |||
| <p>For detailed code implementation, please view it on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/hed" target="_blank">GitHub</a>.</p> | |||
| Below shows an implementation of `Handwritten Equation | |||
| Decipherment <https://proceedings.neurips.cc/paper_files/paper/2019/file/9c19a2aa1d84e04b0bd4bc888792bd1e-Paper.pdf>`__. | |||
| @@ -54,7 +54,7 @@ First, we get the datasets of handwritten equations: | |||
| train_data, val_data = split_equation(total_train_data, 3, 1) | |||
| test_data = get_dataset(train=False) | |||
| The dataset are shown below: | |||
| The datasets are shown below: | |||
| .. code:: ipython3 | |||
| @@ -66,24 +66,24 @@ The dataset are shown below: | |||
| true_train_equation_with_length_5 = true_train_equation[5] | |||
| false_train_equation_with_length_5 = false_train_equation[5] | |||
| print(f"For each euqation length, there are {len(true_train_equation_with_length_5)} " + | |||
| f"true equations and {len(false_train_equation_with_length_5)} false equation " + | |||
| print(f"For each eqaation length, there are {len(true_train_equation_with_length_5)} " + | |||
| f"true equations and {len(false_train_equation_with_length_5)} false equations " + | |||
| f"in the training set.") | |||
| true_val_equation = val_data[1] | |||
| false_val_equation = val_data[0] | |||
| true_val_equation_with_length_5 = true_val_equation[5] | |||
| false_val_equation_with_length_5 = false_val_equation[5] | |||
| print(f"For each euqation length, there are {len(true_val_equation_with_length_5)} " + | |||
| f"true equations and {len(false_val_equation_with_length_5)} false equation " + | |||
| print(f"For each equation length, there are {len(true_val_equation_with_length_5)} " + | |||
| f"true equations and {len(false_val_equation_with_length_5)} false equations " + | |||
| f"in the validation set.") | |||
| true_test_equation = test_data[1] | |||
| false_test_equation = test_data[0] | |||
| true_test_equation_with_length_5 = true_test_equation[5] | |||
| false_test_equation_with_length_5 = false_test_equation[5] | |||
| print(f"For each euqation length, there are {len(true_test_equation_with_length_5)} " + | |||
| f"true equations and {len(false_test_equation_with_length_5)} false equation " + | |||
| print(f"For each equation length, there are {len(true_test_equation_with_length_5)} " + | |||
| f"true equations and {len(false_test_equation_with_length_5)} false equations " + | |||
| f"in the test set.") | |||
| @@ -93,9 +93,9 @@ Out: | |||
| Equations in the dataset is organized by equation length, from 5 to 26. | |||
| For each euqation length, there are 225 true equations and 225 false equation in the training set. | |||
| For each euqation length, there are 75 true equations and 75 false equation in the validation set. | |||
| For each euqation length, there are 300 true equations and 300 false equation in the test set. | |||
| For each equation length, there are 225 true equations and 225 false equations in the training set. | |||
| For each equation length, there are 75 true equations and 75 false equations in the validation set. | |||
| For each equation length, there are 300 true equations and 300 false equations in the test set. | |||
| As illustrations, we show four equations in the training dataset: | |||
| @@ -276,7 +276,7 @@ Bridge Learning and Reasoning | |||
| ----------------------------- | |||
| Now, the last step is to bridge the learning and reasoning part. We | |||
| proceed this step by creating an instance of ``HedBridge``, which is | |||
| proceed with this step by creating an instance of ``HedBridge``, which is | |||
| derived from ``SimpleBridge`` and tailored specific for this task. | |||
| .. code:: ipython3 | |||
| @@ -3,7 +3,7 @@ Handwritten Formula (HWF) | |||
| .. raw:: html | |||
| <p>For detailed code implementation, please view on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/hwf" target="_blank">GitHub</a>.</p> | |||
| <p>For detailed code implementation, please view it on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/hwf" target="_blank">GitHub</a>.</p> | |||
| Below shows an implementation of `Handwritten | |||
| Formula <https://arxiv.org/abs/2006.06649>`__. In this | |||
| @@ -350,7 +350,7 @@ candidate that has the highest consistency. | |||
| confidence derived from the predicted probability. In ``examples/hwf/main.py``, we | |||
| provide options for utilizing other forms of consistency measurement. | |||
| Also, during process of inconsistency minimization, we can | |||
| Also, during the process of inconsistency minimization, we can | |||
| leverage `ZOOpt library <https://github.com/polixir/ZOOpt>`__ for | |||
| acceleration. Options for this are also available in ``examples/hwf/main.py``. Those | |||
| interested are encouraged to explore these features. | |||
| @@ -373,7 +373,7 @@ Bridge Learning and Reasoning | |||
| ----------------------------- | |||
| Now, the last step is to bridge the learning and reasoning part. We | |||
| proceed this step by creating an instance of ``SimpleBridge``. | |||
| proceed with this step by creating an instance of ``SimpleBridge``. | |||
| .. code:: ipython3 | |||
| @@ -3,7 +3,7 @@ MNIST Addition | |||
| .. raw:: html | |||
| <p>For detailed code implementation, please view on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/mnist_add" target="_blank">GitHub</a>.</p> | |||
| <p>For detailed code implementation, please view it on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/mnist_add" target="_blank">GitHub</a>.</p> | |||
| Below shows an implementation of `MNIST | |||
| Addition <https://arxiv.org/abs/1805.10872>`__. In this task, pairs of | |||
| @@ -301,7 +301,7 @@ candidate that has the highest consistency. | |||
| confidence derived from the predicted probability. In ``examples/mnist_add/main.py``, we | |||
| provide options for utilizing other forms of consistency measurement. | |||
| Also, during process of inconsistency minimization, we can leverage | |||
| Also, during the process of inconsistency minimization, we can leverage | |||
| `ZOOpt library <https://github.com/polixir/ZOOpt>`__ for acceleration. | |||
| Options for this are also available in ``examples/mnist_add/main.py``. Those interested are | |||
| encouraged to explore these features. | |||
| @@ -324,7 +324,7 @@ Bridge Learning and Reasoning | |||
| ----------------------------- | |||
| Now, the last step is to bridge the learning and reasoning part. We | |||
| proceed this step by creating an instance of ``SimpleBridge``. | |||
| proceed with this step by creating an instance of ``SimpleBridge``. | |||
| .. code:: ipython3 | |||
| @@ -3,7 +3,7 @@ Zoo | |||
| .. raw:: html | |||
| <p>For detailed code implementation, please view on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/zoo" target="_blank">GitHub</a>.</p> | |||
| <p>For detailed code implementation, please view it on <a class="reference external" href="https://github.com/AbductiveLearning/ABL-Package/tree/Dev/examples/zoo" target="_blank">GitHub</a>.</p> | |||
| Below shows an implementation of | |||
| `Zoo <https://archive.ics.uci.edu/dataset/111/zoo>`__ dataset. In this task, | |||
| @@ -49,9 +49,9 @@ into labeled/unlabeled/test data | |||
| X, y = load_and_preprocess_dataset(dataset_id=62) | |||
| X_label, y_label, X_unlabel, y_unlabel, X_test, y_test = split_dataset(X, y, test_size=0.3) | |||
| Zoo dataset consist of tabular data. The attributes contains 17 boolean | |||
| Zoo dataset consists of tabular data. The attributes contain 17 boolean | |||
| values (e.g., hair, feathers, eggs, milk, airborne, aquatic, etc.) and | |||
| the target is a integer value in range [0,6] representing 7 classes | |||
| the target is an integer value in the range [0,6] representing 7 classes | |||
| (e.g., mammal, bird, reptile, fish, amphibian, insect, and other). Below | |||
| is an illustration: | |||
| @@ -202,7 +202,7 @@ Bridging Learning and Reasoning | |||
| ------------------------------- | |||
| Now, the last step is to bridge the learning and reasoning part. We | |||
| proceed this step by creating an instance of ``SimpleBridge``. | |||
| proceed with this step by creating an instance of ``SimpleBridge``. | |||
| .. code:: ipython3 | |||
| @@ -60,8 +60,8 @@ to obtain the reasoning result. During training, | |||
| alongside the aforementioned forward flow (i.e., prediction --> deduction reasoning), | |||
| there also exists a reverse flow, which starts from the reasoning result and | |||
| involves abductive reasoning ``KBBase.abduce_candidates`` to generate possible revised pseudo-labels. | |||
| Subsequently, these pseudo-labels are processed to minimize inconsistencies with the learning part, | |||
| which in turn revise the outcomes of the learning model, and then | |||
| Subsequently, these pseudo-labels are processed to minimize inconsistencies with the learning part. | |||
| They in turn revise the outcomes of the learning model, which are then | |||
| fed back for further training ``ABLModel.train``. | |||
| .. image:: ../_static/img/usage.png | |||
| @@ -11,7 +11,7 @@ Reasoning part | |||
| =============== | |||
| In this section, we will look at how to build the reasoning part, which | |||
| leverage domain knowledge and perform deductive or abductive reasoning. | |||
| leverages domain knowledge and performs deductive or abductive reasoning. | |||
| In ABL-Package, building the reasoning part involves two steps: | |||
| 1. Build a knowledge base by creating a subclass of ``KBBase``, which | |||
| @@ -292,7 +292,7 @@ base and pseudo-labels predicted by the learning part, and then return **only | |||
| one** candidate that has the highest consistency. | |||
| We can create a reasoner simply by instantiating class | |||
| ``Reasoner`` and passing our knowledge base as an parameter. As an | |||
| ``Reasoner`` and passing our knowledge base as a parameter. As an | |||
| example for MNIST Addition, the reasoner definition would be: | |||
| .. code:: python | |||
| @@ -355,7 +355,7 @@ | |||
| "source": [ | |||
| "Note: During creating reasoner, the definition of \"consistency\" can be customized within the `dist_func` parameter. In the code above, we employ a consistency measurement based on confidence, which calculates the consistency between the data example and candidates based on the confidence derived from the predicted probability. In `main.py`, we provide options for utilizing other forms of consistency measurement.\n", | |||
| "\n", | |||
| "Note: Also, during process of inconsistency minimization, we can leverage [ZOOpt library](https://github.com/polixir/ZOOpt) for acceleration. Options for this are also available in `main.py`. Those interested are encouraged to explore these features." | |||
| "Note: Also, during the process of inconsistency minimization, we can leverage [ZOOpt library](https://github.com/polixir/ZOOpt) for acceleration. Options for this are also available in `main.py`. Those interested are encouraged to explore these features." | |||
| ] | |||
| }, | |||
| { | |||
| @@ -389,7 +389,7 @@ | |||
| "source": [ | |||
| "## Bridge Learning and Reasoning\n", | |||
| "\n", | |||
| "Now, the last step is to bridge the learning and reasoning part. We proceed this step by creating an instance of `SimpleBridge`." | |||
| "Now, the last step is to bridge the learning and reasoning part. We proceed with this step by creating an instance of `SimpleBridge`." | |||
| ] | |||
| }, | |||
| { | |||
| @@ -390,7 +390,7 @@ | |||
| "source": [ | |||
| "Note: During creating reasoner, the definition of \"consistency\" can be customized within the `dist_func` parameter. In the code above, we employ a consistency measurement based on confidence, which calculates the consistency between the data example and candidates based on the confidence derived from the predicted probability. In `main.py`, we provide options for utilizing other forms of consistency measurement.\n", | |||
| "\n", | |||
| "Note: Also, during process of inconsistency minimization, one can leverage [ZOOpt library](https://github.com/polixir/ZOOpt) for acceleration. Options for this are also available in `main.py`. Those interested are encouraged to explore these features." | |||
| "Note: Also, during the process of inconsistency minimization, one can leverage [ZOOpt library](https://github.com/polixir/ZOOpt) for acceleration. Options for this are also available in `main.py`. Those interested are encouraged to explore these features." | |||
| ] | |||
| }, | |||
| { | |||
| @@ -424,7 +424,7 @@ | |||
| "source": [ | |||
| "## Bridging Learning and Reasoning\n", | |||
| "\n", | |||
| "Now, the last step is to bridge the learning and reasoning part. We proceed this step by creating an instance of `SimpleBridge`." | |||
| "Now, the last step is to bridge the learning and reasoning part. We proceed with this step by creating an instance of `SimpleBridge`." | |||
| ] | |||
| }, | |||
| { | |||
| @@ -56,7 +56,7 @@ | |||
| "cell_type": "markdown", | |||
| "metadata": {}, | |||
| "source": [ | |||
| "Zoo dataset consist of tabular data. The attributes contains 17 boolean values (e.g., hair, feathers, eggs, milk, airborne, aquatic, etc.) and the target is a integer value in range [0,6] representing 7 classes (e.g., mammal, bird, reptile, fish, amphibian, insect, and other). Below is an illustration:" | |||
| "Zoo dataset consists of tabular data. The attributes contain 17 boolean values (e.g., hair, feathers, eggs, milk, airborne, aquatic, etc.) and the target is an integer value in the range [0,6] representing 7 classes (e.g., mammal, bird, reptile, fish, amphibian, insect, and other). Below is an illustration:" | |||
| ] | |||
| }, | |||
| { | |||
| @@ -275,7 +275,7 @@ | |||
| "source": [ | |||
| "## Bridging Learning and Reasoning\n", | |||
| "\n", | |||
| "Now, the last step is to bridge the learning and reasoning part. We proceed this step by creating an instance of `SimpleBridge`." | |||
| "Now, the last step is to bridge the learning and reasoning part. We proceed with this step by creating an instance of `SimpleBridge`." | |||
| ] | |||
| }, | |||
| { | |||