Skip to content

Commit a86c478

Browse files
committed
Release: NS AI Summer School
Signed-off-by: KyleErwin <[email protected]>
1 parent 02b11a2 commit a86c478

File tree

338 files changed

+47936
-14488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

338 files changed

+47936
-14488
lines changed

.github/workflows/black.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10-
- uses: psf/black@stable
10+
- uses: psf/black@stable

.github/workflows/build.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ jobs:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Upgrade pip
2626
run: python -m pip install --upgrade pip setuptools wheel
27+
- name: Install graphviz
28+
run: sudo apt-get install -y libgraphviz-dev
2729
- name: Install dependencies
2830
run: pip install -e .[test]
31+
- name: Install dependencies
32+
run: pip install pytest
2933
- name: Run tests with ${{ matrix.args }}
30-
run: pytest ${{ matrix.args }}
34+
run: pytest ${{ matrix.args }}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ dmypy.json
129129
# Pyre type checker
130130
.pyre/
131131

132+
# TODO files
133+
TODO
134+
132135
# tmp files
133136
*tmp.*
134137
___*___

.pre-commit-config.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
files: '.*\.(py|md|)'
8+
- id: trailing-whitespace
9+
- repo: https://github.com/psf/black
10+
rev: 22.3.0
11+
hooks:
12+
- id: black

CODE_OF_CONDUCT.md

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
2+
# Contributor Covenant Code of Conduct
3+
4+
## Our Pledge
5+
6+
We as members, contributors, and leaders pledge to make participation in our
7+
community a harassment-free experience for everyone, regardless of age, body
8+
size, visible or invisible disability, ethnicity, sex characteristics, gender
9+
identity and expression, level of experience, education, socio-economic status,
10+
nationality, personal appearance, race, caste, color, religion, or sexual
11+
identity and orientation.
12+
13+
We pledge to act and interact in ways that contribute to an open, welcoming,
14+
diverse, inclusive, and healthy community.
15+
16+
## Our Standards
17+
18+
Examples of behavior that contributes to a positive environment for our
19+
community include:
20+
21+
* Demonstrating empathy and kindness toward other people
22+
* Being respectful of differing opinions, viewpoints, and experiences
23+
* Giving and gracefully accepting constructive feedback
24+
* Accepting responsibility and apologizing to those affected by our mistakes,
25+
and learning from the experience
26+
* Focusing on what is best not just for us as individuals, but for the overall
27+
community
28+
29+
Examples of unacceptable behavior include:
30+
31+
* The use of sexualized language or imagery, and sexual attention or advances of
32+
any kind
33+
* Trolling, insulting or derogatory comments, and personal or political attacks
34+
* Public or private harassment
35+
* Publishing others' private information, such as a physical or email address,
36+
without their explicit permission
37+
* Other conduct which could reasonably be considered inappropriate in a
38+
professional setting
39+
40+
## Enforcement Responsibilities
41+
42+
Community leaders are responsible for clarifying and enforcing our standards of
43+
acceptable behavior and will take appropriate and fair corrective action in
44+
response to any behavior that they deem inappropriate, threatening, offensive,
45+
or harmful.
46+
47+
Community leaders have the right and responsibility to remove, edit, or reject
48+
comments, commits, code, wiki edits, issues, and other contributions that are
49+
not aligned to this Code of Conduct, and will communicate reasons for moderation
50+
decisions when appropriate.
51+
52+
## Scope
53+
54+
This Code of Conduct applies within all community spaces, and also applies when
55+
an individual is officially representing the community in public spaces.
56+
Examples of representing our community include using an official e-mail address,
57+
posting via an official social media account, or acting as an appointed
58+
representative at an online or offline event.
59+
60+
## Enforcement
61+
62+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
63+
reported to the community leaders responsible for enforcement at
64+
[INSERT CONTACT METHOD].
65+
All complaints will be reviewed and investigated promptly and fairly.
66+
67+
All community leaders are obligated to respect the privacy and security of the
68+
reporter of any incident.
69+
70+
## Enforcement Guidelines
71+
72+
Community leaders will follow these Community Impact Guidelines in determining
73+
the consequences for any action they deem in violation of this Code of Conduct:
74+
75+
### 1. Correction
76+
77+
**Community Impact**: Use of inappropriate language or other behavior deemed
78+
unprofessional or unwelcome in the community.
79+
80+
**Consequence**: A private, written warning from community leaders, providing
81+
clarity around the nature of the violation and an explanation of why the
82+
behavior was inappropriate. A public apology may be requested.
83+
84+
### 2. Warning
85+
86+
**Community Impact**: A violation through a single incident or series of
87+
actions.
88+
89+
**Consequence**: A warning with consequences for continued behavior. No
90+
interaction with the people involved, including unsolicited interaction with
91+
those enforcing the Code of Conduct, for a specified period of time. This
92+
includes avoiding interactions in community spaces as well as external channels
93+
like social media. Violating these terms may lead to a temporary or permanent
94+
ban.
95+
96+
### 3. Temporary Ban
97+
98+
**Community Impact**: A serious violation of community standards, including
99+
sustained inappropriate behavior.
100+
101+
**Consequence**: A temporary ban from any sort of interaction or public
102+
communication with the community for a specified period of time. No public or
103+
private interaction with the people involved, including unsolicited interaction
104+
with those enforcing the Code of Conduct, is allowed during this period.
105+
Violating these terms may lead to a permanent ban.
106+
107+
### 4. Permanent Ban
108+
109+
**Community Impact**: Demonstrating a pattern of violation of community
110+
standards, including sustained inappropriate behavior, harassment of an
111+
individual, or aggression toward or disparagement of classes of individuals.
112+
113+
**Consequence**: A permanent ban from any sort of public interaction within the
114+
community.
115+
116+
## Attribution
117+
118+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119+
version 2.1, available at
120+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121+
122+
Community Impact Guidelines were inspired by
123+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124+
125+
For answers to common questions about this code of conduct, see the FAQ at
126+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
127+
[https://www.contributor-covenant.org/translations][translations].
128+
129+
[homepage]: https://www.contributor-covenant.org
130+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131+
[Mozilla CoC]: https://github.com/mozilla/diversity
132+
[FAQ]: https://www.contributor-covenant.org/faq
133+
[translations]: https://www.contributor-covenant.org/translations
134+

CONTRIBUTING.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
# Contributing to LNN
3+
Thank you for considering a contribution to Logical Neural Networks, with your assistance we can help grow LNNs as the industry's tool of choice for a true `Neuro = Symbolic` platform.
4+
5+
We commit to growing LNNs functionality, but we'd also love to see your name expanding into `x`, adding to growing our list of contributors:
6+
```python
7+
Contributions = Predicate("Contribution")
8+
Growth = Propostion("LNNs Growth", world=World.TRUE)
9+
10+
Implies(Contributions(x), Growth)
11+
```
12+
13+
## Software Setup
14+
15+
* Due to the complex inference pattern of LNNs upward and downward reasoning strategy, [Pycharm](https://www.jetbrains.com/pycharm/download/) is our recommended IDE of choice for development and debugging.
16+
1. Make sure that the python version you are using corresponds with the [setup](https://github.com/IBM/LNN/blob/master/setup.py) file, using a fresh [conda]() environment is recommended:
17+
```commandline
18+
conda create -n lnn-contrib python=3.9 -y
19+
conda activate lnn-contrib
20+
```
21+
2. Clone the `develop` branch to keep up to date with the latest supported features:
22+
```commandline
23+
git clone https://github.ibm.com/Naweed-Khan/LNN.git -b develop
24+
```
25+
3. Install the LNN module as editable and use the `develop` branch
26+
```commandline
27+
cd LNN
28+
pip install -e .
29+
```
30+
* Install [Black](https://black.readthedocs.io/en/stable/integrations/editors.html) as an external tool/keyboard shortcut to keep to our code style - this automates our pep8 compliance so that you can code without the styling overhead
31+
* Install and run pytest to ensure that the build is working correctly:
32+
```commandline
33+
pip install pytest
34+
pytest
35+
```
36+
37+
You are now ready to contribute changes to the codebase
38+
39+
## Developing in LNN
40+
41+
### Propose a New Issue
42+
43+
1. You want to propose a new feature and implement it.
44+
1. Post about your intended feature in an [issue](https://github.com/IBM/LNN/issues/new), and we shall discuss the design and implementation.
45+
2. Once we agree that the plan looks good, go ahead and implement it.
46+
47+
* You may also want to implement a feature or bug-fix for an outstanding issue:
48+
* Pick an issue
49+
* Comment that you will be working on this issue.
50+
* Add yourself to the assignee list
51+
52+
If you need more context on a particular issue, please ask for guidance.
53+
54+
### Branching
55+
56+
* LNN branches should follow [git flow][git flow] style branching
57+
58+
[<img src="https://wac-cdn.atlassian.com/dam/jcr:34c86360-8dea-4be4-92f7-6597d4d5bfae/02%20Feature%20branches.svg?cdnVersion=296" alt="git flow"/>][git flow]
59+
60+
To create a new feature branch:
61+
```commandline
62+
git checkout develop
63+
git checkout -b feature/my_branch
64+
```
65+
66+
Please be mindful of existing branches when creating a new branch.
67+
68+
### Pull Requests
69+
70+
1. Use `Black` formatting to ensure that code contributions abide by our code style
71+
2. Commits should contain one of the following tags before the commit message: `ADD`, `FIX`, `MAINT`
72+
3. Run `pytest` locally to ensure all changes pass
73+
74+
NB: All code contributions corresponding to `enhancement` issues should have additional tests accompanying the code changes, located in the `tests/` folder.
75+
4. Propose your code changes as a `Pull Request DRAFT` that merge into the `develop` branch.
76+
5. A passed draft can be changed to a formal `Pull Request`.
77+
6. Add a reviewer to your code so that they can get notified of the proposal - the individual should correspond to the those charged with the yellow tag
78+
79+
### Documentation
80+
81+
LNN documentation can be generated by running `generate_docs.sh` in [docsrc][docsrc] folder.
82+
83+
[docsrc]: https://github.com/IBM/LNN/tree/develop/docsrc
84+
[git flow]: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
85+
86+
### Handling Circular Imports
87+
88+
A key component in the LNN code base is the `Formula` abstract class. `Formula` is a
89+
class that refers to itself and the classes that inherit from it. As such, this can lead
90+
to circular imports. To overcome circular imports we use dictionaries that are keyed
91+
with the names of the subclasses and the values are the subclasses themselves. These
92+
dictionaries are populated in the `__init__.py` of the logic module. Thus, when one
93+
needs to work with a subclass, the subclass can be accessed by passing in the name of
94+
that subclass to the dictionary. Note that not all classes that inherit from `Formula`
95+
are added to these dictionaries. Please refer to `__init__.py` if you need to add an
96+
existing class or new class to one of the dictionaries.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) IBM Corporation 2018-2020
1+
Copyright (C) IBM Corporation 2018-2022
22

33
Apache License
44
Version 2.0, January 2004

README.md

+42-29
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,59 @@
1-
[![Build Status](https://github.com/IBM/LNN/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/IBM/LNN/actions/workflows/build.yml?query=branch%3Amaster)
2-
[![License](https://img.shields.io/github/license/IBM/LNN)](https://github.com/IBM/LNN/blob/master/LICENSE)
1+
[![License](https://img.shields.io/badge/license-Apache%202.0-blueviolet)](https://github.com/IBM/LNN/blob/master/LICENSE)
2+
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5926/badge)](https://bestpractices.coreinfrastructure.org/projects/5926)
33
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
44

55
# Logical Neural Networks
6-
LNNs are a novel `Neuro = symbolic` framework designed to seamlessly provide key
6+
LNNs are a novel `Neuro = Symbolic` framework designed to seamlessly provide key
77
properties of both neural nets (learning) and symbolic logic (knowledge and reasoning).
88

9-
- Every neuron has a meaning as a component of a formula in a weighted
10-
real-valued logic, yielding a highly interpretable disentangled representation.
9+
- Every neuron has a meaning as a component of a formula in a weighted
10+
real-valued logic, yielding a highly interpretable disentangled representation.
1111
- Inference is omnidirectional rather than focused on predefined target
1212
variables, and corresponds to logical reasoning, including classical
13-
first-order logic (FOL) theorem proving as a special case.
14-
- The model is end-to-end differentiable, and learning minimizes a novel loss
13+
first-order logic theorem proving as a special case.
14+
- The model is end-to-end differentiable, and learning minimizes a novel loss
1515
function capturing logical contradiction, yielding resilience to inconsistent
16-
knowledge.
16+
knowledge.
1717
- It also enables the open-world assumption by maintaining bounds on truth values
18-
which can have probabilistic semantics, yielding resilience to incomplete
18+
which can have probabilistic semantics, yielding resilience to incomplete
1919
knowledge.
2020

2121
## Quickstart
22-
2322
To install the LNN:
24-
1. Run:
25-
```
26-
pip install git+https://github.com/IBM/LNN.git
27-
```
28-
29-
To install the LNN with graph plot support:
30-
1. Install [GraphViz](https://www.graphviz.org/download/)
31-
2. Run:
32-
```
33-
pip install git+https://github.com/IBM/LNN.git#egg=lnn"[plot]"
34-
```
23+
1. Install [GraphViz](https://www.graphviz.org/download/) and gmp (libgmp3-dev)
24+
<details><summary>Tips for errors "'gmp.h' file not found" and "'graphviz/cgraph.h' file not found" on Mac</summary><div>
3525

36-
## Documentation
26+
```bash
27+
brew install graphviz
28+
# check the graphviz path from `brew info graphviz`
29+
export GRAPHVIZ_DIR="/usr/local/Cellar/graphviz/3.0.0"
30+
pip install pygraphviz --global-option=build_ext --global-option="-I$GRAPHVIZ_DIR/include" --global-option="-L$GRAPHVIZ_DIR/lib"
31+
32+
brew install gmp
33+
env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycddlib
34+
```
35+
</div></details>
36+
37+
2. Make sure that the python version you use in line with our [setup](https://github.com/IBM/LNN/blob/master/setup.py) file, using a fresh environment is always a good idea:
38+
```commandline
39+
conda create -n lnn-contrib python=3.9 -y
40+
conda activate lnn-contrib
41+
```
42+
3. Install the `develop` branch to keep up to date with the latest supported features:
43+
```commandline
44+
pip install git+https://github.com/IBM/LNN.git@develop
45+
```
3746

47+
## Contribution
48+
Contributions to the LNN codebase are welcome!
49+
50+
Please have a look at the [contribution guide](https://github.com/IBM/LNN/blob/master/CONTRIBUTING.md) for more information on how to set up the LNN for contributing and how to follow our development standards.
51+
52+
## Documentation
3853
| [Read the Docs][Docs] | [Academic Papers][Papers] | [Educational Resources][Education] | [Neuro-Symbolic AI][Neuro-Symbolic AI] | [API Overview][API] | [Python Module][Module] |
3954
|:-----------------------:|:---------------------------:|:-----------------:|:----------:|:-------:|:-------:|
4055
| [<img src=https://raw.githubusercontent.com/IBM/LNN/master/docsrc/images/icons/doc.png alt="Docs" width="60"/>][Docs] | [<img src=https://raw.githubusercontent.com/IBM/LNN/master/docsrc/images/icons/academic.png alt="Academic Papers" width="60"/>][Papers] | [<img src=https://raw.githubusercontent.com/IBM/LNN/master/docsrc/images/icons/help.png alt="Getting Started" width="60"/>][Education] | [<img src=https://raw.githubusercontent.com/IBM/LNN/master/docsrc/images/icons/nsai.png alt="Neuro-Symbolic AI" width="60"/>][Neuro-Symbolic AI] | [<img src=https://raw.githubusercontent.com/IBM/LNN/master/docsrc/images/icons/api.png alt="API" width="60"/>][API] | [<img src=https://raw.githubusercontent.com/IBM/LNN/master/docsrc/images/icons/python.png alt="Python Module" width="60"/>][Module] |
4156

42-
4357
## Citation
4458
If you use Logical Neural Networks for research, please consider citing the
4559
reference paper:
@@ -52,10 +66,9 @@ reference paper:
5266
}
5367
```
5468

55-
56-
[Docs]: https://ibm.github.io/LNN/
57-
[Papers]: https://ibm.github.io/LNN/papers.html
58-
[Education]: https://ibm.github.io/LNN/education/education.html
59-
[API]: https://ibm.github.io/LNN/usage.html
60-
[Module]: https://ibm.github.io/LNN/lnn/LNN.html
69+
[Docs]: https://pages.github.com/IBM/LNN/introduction.html
70+
[Papers]: https://pages.github.com/IBM/LNN/papers.html
71+
[Education]: https://pages.github.com/IBM/LNN/education/education.html
72+
[API]: https://pages.github.com/IBM/LNN/usage.html
73+
[Module]: https://pages.github.com/IBM/LNN/lnn/LNN.html
6174
[Neuro-Symbolic AI]: https://research.ibm.com/teams/neuro-symbolic-ai

docs/.buildinfo

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 976870eaa406da43ff4c506ff5c2007d
3+
config: b84c77634a33cf724ade5aeb967569d8
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/_images/class_diagram.png

135 KB
Loading

docs/_images/raining_implies_wet.png

26.5 KB
Loading
197 KB
Loading

0 commit comments

Comments
 (0)