logictensornetworks/logictensornetworks
Deep Learning and Logical Reasoning from Data and Knowledge
What it solves
Machine learning models normally learn from raw data alone, while symbolic logic systems can reason with abstract knowledge but struggle to learn from messy data. Logic Tensor Networks (LTN) bridges this gap by letting you combine both: you can express background knowledge, constraints, and queries in a first-order logic language, and use them together with data to train neural networks or evaluate logical statements.
How it works
LTN uses a differentiable logic called Real Logic. You write formulas like "for all x, if x is a cat then there exists y such that y is a tail and a part of x". LTN translates these formulas into TensorFlow computational graphs, so the truth values become numbers that can be optimized with backpropagation. The framework provides core building blocks for constants, variables, predicates, functions, connectives, and quantifiers, plus a collection of fuzzy logic operators. You can use the satisfaction of a set of formulas as a training objective (learning) or measure whether a formula is a logical consequence of a knowledge base (reasoning).
Who it's for
Researchers and practitioners in neurosymbolic AI who want to combine deep learning with logical reasoning. It suits tasks like classification, regression, clustering, and link prediction when you have both data and prior knowledge (for example, constraints on intermediate labels or relations between entities). The repository includes tutorials and runnable examples in Jupyter notebooks and Python scripts.
Highlights
- Differentiable first-order logic (Real Logic) integrated with TensorFlow 2.
- Supports querying, learning, and reasoning using logic formulas.
- Includes tutorials covering grounding, connectives, learning, and reasoning.
- Provides examples for binary/multiclass classification, regression, clustering, MNIST digit addition, and link prediction.
- Original TensorFlow implementation; a PyTorch port is also linked.
Related
- Project
- Project
- Project
- Project