Agents and LRNN in 2P-Kt
Agents and LRNN in 2P-Kt
Author
Abstract
In the last few years neural network have proven to be a quite efficient tool to solve complex problems, unfortunately they lack the interpretability and expressive power of first-order logic; Lifted Relational Neural Networks (LRNN) have been proposed to tackle this problem.
In particular, the latent relational structure of a given problem is described by a set of first-order logic rules that are then used to create a number of neural networks, one for each example.
Given that the problem setting is shared by all the examples, the corresponding neural networks share their weights and these can be efficiently learned using stochastic gradient descent.
2P-Kt is a Kotlin-based and multi-platform multi-paradigm logic programming framework based on tuProlog.
It aims at becoming an open ecosystem for Symbolic Artificial Intelligence, and it does so by providing a set of inter-dependent modules supporting knowledge representation and automatic reasoning through logic programming.
Material
Online Report |
Summary
This project goal is to add to 2P-Kt a module that provides an implementation of LRNN, this will be obtained by leveraging on the official implementation of LRNN, NeuraLogic, available in github.
The expected deliverable is a module that uses existing modules of 2P-Kt to provide the description of a problem and then relies on NeuraLogic to construct the NNs, associated to the examples written with 2P-Kt, and to learn their weights through stochastic gradient descent.
In order to reach this goal the project could be divided into the following steps:
- Create classes/sub-types from interfaces of Fact and Rule to deal with weighted clauses
- Provide a way to save template, examples and queries in '.txt' files, using string formatter
2. Provide a way to create additional test queries and to use the learned weights to perform inference
2. Check template to avoid cycles - Create a Solver that calls NeuraLogic with path to the files created in (2)
- Check queries in order to avoid using those not matched in the ground network (NeuraLogic stops with error)
NeuraLogic
As of 04/2020, commit: ac33e94
Value Hierarchy
Value
Abstact class provided in package cz.cvut.fel.ida.algebra.values, implements Iterable<Double>, Comparable<Value> and Serializable.
ScalarValue
VectorValue
MatrixValue
One, Zero
ScalarValue constants used to make operations faster.
TensorValue
This class is a work in progress.
Weight
Provided in package cz.cvut.fel.ida.algebra.weights.
It should be created via a factory.
Term Hierarchy
Term
Provided in package cz.cvut.fel.ida.logic, implements Serializable
Variable
Implements Term.
Constant
Implements Term.
Weighted Fact
Weighted Rule
Template Hierarchy
Template
Implements Model<QueryAtom> and Exportable.
Neuralizer
Implements exportable.
NeuralProcessingSample
Extends NeuralSample (Defined in "Neural/src/main/java/cz/cvut/fel/ida/neural/networks/computation/training/NeuralSample.java")
Query Hierarchy
Query<E extends Example, M extends Model>
Abstract class, provided in package cz.cvut.fel.ida.learning, implements Exportable.
QueryNeuron
Provided in package cz.cvut.fel.ida.neural.networks.structure.components.neurons, extends Query<NeuralNetwork<State.Neural.Structure>, NeuralModel>.
Model Hierarchy
Interface Model<T extends Query>
Provided in package cz.cvut.fel.ida.learning.
NeuralModel
It is provided in package cz.cvut.fel.ida.neural.networks.computation.training and implements Model<QueryNeuron>.
NeuralSample
It is provided in package cz.cvut.fel.ida.neural.networks.computation.training and extends LearningSample<QueryNeuron, Object> .
End2endTrainigBuilder
Provided in package cz.cvut.fel.ida.pipelines.building; Extends extends AbstractPipelineBuilder<Sources, Pair<Pair<Template, NeuralModel>, Progress>>.
LRNN Module 2P-Kt
This module provides an interface between 2P-kt and NeuraLogic, in particular the classes FactProb and RuleProb can be used to go from 2P-kt's facts and rules to a format accepted by NeuraLogic, by associating them with weights and providing a way to create files in the format required by NeuraLogic's Pipelines.
The class Sources is used to work with NeuraLogic's Sources and Settings, in order to change the parameters and the files to be used by the Pipeline.
Activation is an enumeration class from which the user can choose the activation function to be used during training.
More information are available in the README.md of the repository.
LRNN Solver
Leverages on the CLI and Pipelines modules of NeuraLogic to provided learning and inference functions to users.
An example of usage is provided in it.unibo.tuprolog.lrnn.Example.kt
Sources
Provided in package it.unibo.tuprolog.lrnn.sources.
FactProb
Provided in package it.unibo.tuprolog.lrnn.clauses.
RuleProb
Provided in package it.unibo.tuprolog.lrnn.clauses.
Activation
Enum class provided in package it.unibo.tuprolog.lrnn.clauses.
Repo