Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files for readthedocs #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.8"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
problog
torchvision
torch
furo
55 changes: 55 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here.
#import pathlib
#import sys
#sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())

import sys
import os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

sys.path.insert(0, os.path.abspath("../../"))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'DeepStochLog'
copyright = '2023, KU Leuven, DTAI Research Group'
author = 'KU Leuven, DTAI Research Group'
# release = '1.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.graphviz",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"sphinx.ext.inheritance_diagram",
]

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
103 changes: 103 additions & 0 deletions docs/source/deepstochlog_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
API Documentation
=================

context
----------
.. automodule:: deepstochlog.context
:members:


dataloader
----------
.. autoclass:: deepstochlog.dataloader.DataLoader
:members:


dataset
----------
.. automodule:: deepstochlog.dataset
:members:


inferences
----------
.. automodule:: deepstochlog.inferences
:members:


logic
----------
.. automodule:: deepstochlog.logic
:members:


model
----------
.. autoclass:: deepstochlog.model.DeepStochLogModel
:members:


network
----------
.. autoclass:: deepstochlog.network.Network
:members:

.. autoclass:: deepstochlog.network.NetworkStore
:members:


networkevaluation
-----------------
.. autoclass:: deepstochlog.networkevaluation.RequiredEvaluation
:members:

.. autoclass:: deepstochlog.networkevaluation.PreparedEvaluation
:members:


nn_models
-----------------
.. autoclass:: deepstochlog.nn_models.TrainableProbability
:members:


parser
----------
.. automodule:: deepstochlog.parser
:members:


rule
----------
.. automodule:: deepstochlog.rule
:members:


tabled_and_or_trees
-------------------
.. automodule:: deepstochlog.tabled_and_or_trees
:members:


tabled_tree_builder
-------------------
.. automodule:: deepstochlog.tabled_tree_builder
:members:


term
-------------------
.. automodule:: deepstochlog.term
:members:


trainer
-------------------
.. automodule:: deepstochlog.trainer
:members:


utils
-------------------
.. automodule:: deepstochlog.utils
:members:
46 changes: 46 additions & 0 deletions docs/source/deepstochlog_download.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Download
===============================================

Installation
------------
DeepStochLog requires SWI Prolog to run. Run the following commands to install:

.. code-block:: bash

sudo apt-add-repository ppa:swi-prolog/stable
sudo apt-get update
sudo apt-get install swi-prolog

To install DeepStochLog itself, run the following command:

.. code-block:: bash

pip install deepstochlog


Requirements
------------

DeepStochLog has the following requirements:

* torch~=1.5.1
* torchvision~=0.6.1
* numpy~=1.18.1
* pandas~=1.2.4
* pyparsing~=2.4.7
* dgl~=0.6.1


Running the examples
--------------------
**Local dependencies**
To see DeepStochLog in action, please first install SWI Prolog (as explained about), as well as all requirements.

**Datasets**
The datasets used in the tasks used to evaluate DeepStochLog can be found `here <https://github.com/ML-KULeuven/deepstochlog/releases/tag/0.0.1>`_.

**Addition example**
To see DeepStochLog in action, navigate to ``examples/addition`` and run ``addition.py`` in the `github repo <https://github.com/ML-KULeuven/deepstochlog/tree/main>`_.
The neural definite clause grammar specification is provided in ``addition.pl``.
The ``addition(N)`` predicate specifies/recognises that two handwritten digits *N1* and *N2* sum to *N*.
The neural probability ``nn(number, [X], Y, digit)`` makes the neural network with name ``number`` (a MNIST classifier) label input image X with the digit Y.
26 changes: 26 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. DeepStochLog documentation master file, created by
sphinx-quickstart on Tue Aug 8 11:25:48 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

DeepStochLog
=======================================
Welcome to DeepStochLog's documentation.

DeepStochLog is a neuro-symbolic framework that combines grammars, logic, probabilities and neural networks. By writing a DeepStochLog program, one can train a neural network with the given background knowledge. One can express symbolic information about subsymbolic data in DeepStochLog and help train neural networks more efficiently this way.

.. toctree::
:maxdepth: 2
:caption: Contents:

Install <deepstochlog_download>
Api <deepstochlog_api>



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`