Browse Source

[DOC] resolve some comments

pull/1/head
troyyyyy 2 years ago
parent
commit
42c6060930
4 changed files with 6 additions and 35 deletions
  1. +0
    -11
      abl/learning/abl_model.py
  2. +0
    -12
      abl/learning/basic_nn.py
  3. +2
    -1
      docs/Intro/Learning.rst
  4. +4
    -11
      docs/Intro/Quick-Start.rst

+ 0
- 11
abl/learning/abl_model.py View File

@@ -1,14 +1,3 @@
# coding: utf-8
# ================================================================#
# Copyright (C) 2020 Freecss All rights reserved.
#
# File Name :models.py
# Author :freecss
# Email :karlfreecss@gmail.com
# Created Date :2020/04/02
# Description :
#
# ================================================================#
import pickle
from typing import Any, Dict



+ 0
- 12
abl/learning/basic_nn.py View File

@@ -1,15 +1,3 @@
# coding: utf-8
# ================================================================#
# Copyright (C) 2020 Freecss All rights reserved.
#
# File Name :basic_model.py
# Author :freecss
# Email :karlfreecss@gmail.com
# Created Date :2020/11/21
# Description :
#
# ================================================================#

import os
import logging
from typing import Any, Callable, List, Optional, T, Tuple


+ 2
- 1
docs/Intro/Learning.rst View File

@@ -21,7 +21,7 @@ Learning Part

self.base_model = base_model

All scikit-learn models satisify this requiremnts, so we can directly use the model to create an instance of ``ABLModel``. For example, we can customize our machine learning model by
All scikit-learn models satisify this requirements, so we can directly use the model to create an instance of ``ABLModel``. For example, we can customize our machine learning model by

.. code:: python

@@ -36,6 +36,7 @@ For a PyTorch-based neural network, we first need to encapsulate it within a ``B
.. code:: python

# Load a PyTorch-based neural network
import torchvision
cls = torchvision.models.resnet18(pretrained=True)

# criterion and optimizer are used for training


+ 4
- 11
docs/Intro/Quick-Start.rst View File

@@ -72,7 +72,7 @@ ABL-Package offers several `dataset classes <../API/abl.dataset.html>`_ for diff

Read more about `preparing datasets <Datasets.html>`_.

Building the Machine Learning Part
Building the Learning Part
----------------------------------

To build the machine learning part, we need to wrap our machine learning model into the ``ABLModel`` class. The machine learning model can either be a scikit-learn model or a PyTorch neural network. We use a simple LeNet5 in the MNIST Add example.
@@ -141,13 +141,6 @@ function specifying how to perform (deductive) reasoning.
return sum(nums)

kb = AddKB(pseudo_label_list=list(range(10)))
print(kb)

Out:

.. code-block:: none

AddKB is a KB with pseudo_label_list=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], max_err=1e-10, use_cache=True.

Then, we create a reasoner by defining an instance of class
``ReasonerBase`` and passing the knowledge base as an parameter.
@@ -178,10 +171,10 @@ In the case of MNIST Add example, the metric definition looks like

Read more about `building evaluation metrics <Evaluation.html>`_

Bridging Machine Learning and Reasoning
Bridging Learning and Reasoning
---------------------------------------

Now, we use ``SimpleBridge`` to combine machine learning and reasoning together.
Now, we use ``SimpleBridge`` to combine learning and reasoning in a unified model.

.. code:: python

@@ -189,7 +182,7 @@ Now, we use ``SimpleBridge`` to combine machine learning and reasoning together.

bridge = SimpleBridge(model, reasoner, metric_list)

Finally, we proceed with testing and training.
Finally, we proceed with training and testing.

.. code:: python



Loading…
Cancel
Save