Skip to content

Commit 5128919

Browse files
Merge pull request #3 from intsystems/docs
Docs
2 parents ffe1be9 + 4387568 commit 5128919

File tree

8 files changed

+205
-19
lines changed

8 files changed

+205
-19
lines changed

doc/source/conf.py

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
113
import os
214
import sys
3-
sys.path.insert(0, os.path.abspath('../..'))
15+
16+
sys.path.insert(0, os.path.abspath('../../src/'))
17+
18+
from mylib import __version__
19+
20+
21+
# -- Project information -----------------------------------------------------
422

523
project = 'Implicit Reparametrization Trick'
24+
copyright = '2024, Matvei Kreinin, Maria Nikitina, Petr Babkin, Irina Zaboryanskaya'
625
author = 'Matvei Kreinin, Maria Nikitina, Petr Babkin, Irina Zaboryanskaya'
7-
release = '0.1'
26+
27+
version = __version__
28+
master_doc = 'index'
29+
30+
# -- General configuration ---------------------------------------------------
31+
32+
# Add any Sphinx extension module names here, as strings. They can be
33+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
34+
# ones.
35+
=======
836

937
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest',
1038
'sphinx.ext.intersphinx', 'sphinx.ext.todo',
@@ -13,20 +41,37 @@
1341
'sphinx.ext.autosummary', 'sphinx.ext.mathjax',
1442
'sphinx_rtd_theme']
1543

44+
=======
45+
1646
autodoc_mock_imports = ["numpy", "scipy", "sklearn", "torch"]
1747

48+
# Add any paths that contain templates here, relative to this directory.
1849
templates_path = ['_templates']
50+
51+
# List of patterns, relative to source directory, that match files and
52+
# directories to ignore when looking for source files.
53+
# This pattern also affects html_static_path and html_extra_path.
1954
exclude_patterns = []
2055

2156
html_extra_path = []
2257

2358
html_context = {
24-
"display_github": True,
25-
"github_user": "Intelligent-Systems-Phystech",
26-
"github_repo": "ProjectTemplate",
27-
"github_version": "master",
28-
"conf_py_path": "/doc/source/",
59+
"display_github": True, # Integrate GitHub
60+
"github_user": "Intelligent-Systems-Phystech", # Username
61+
"github_repo": "ProjectTemplate", # Repo name
62+
"github_version": "master", # Version
63+
"conf_py_path": "/doc/source/", # Path in the checkout to the docs root
2964
}
3065

66+
67+
# -- Options for HTML output -------------------------------------------------
68+
69+
# The theme to use for HTML and HTML Help pages. See the documentation for
70+
# a list of builtin themes.
71+
#
3172
html_theme = 'sphinx_rtd_theme'
73+
74+
# Add any paths that contain custom static files (such as style sheets) here,
75+
# relative to this directory. They are copied after the builtin static files,
76+
# so a file named "default.css" will overwrite the builtin "default.css".
3277
html_static_path = ['_static']

doc/source/distributions.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*****
2+
Distributions
3+
*****
4+
5+
.. automodule:: irt.distributions
6+
:members:
7+
8+

doc/source/index.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1-
.. Implicit Reparametrization Trick documentation master file, created by
2-
sphinx-quickstart on Mon Oct 10 10:00:00 2022.
1+
.. MixtureLib documentation master file, created by
2+
sphinx-quickstart on Fri Mar 20 22:58:28 2020.
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
Welcome to Implicit Reparametrization Trick's documentation!
7-
===========================================================
6+
Welcome to Mixture Lib!
7+
=======================
88

99
.. toctree::
10-
:maxdepth: 2
11-
:caption: Contents:
10+
:maxdepth: 1
11+
:caption: Main Info:
12+
13+
info.rst
1214

13-
modules
15+
.. toctree::
16+
:maxdepth: 1
17+
:caption: Get Started:
18+
19+
installation.rst
20+
21+
22+
.. toctree::
23+
:maxdepth: 1
24+
:caption: Packages:
25+
26+
distributions.rst
27+
28+
29+
Indices and tables
30+
==================

doc/source/installation.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../../src/README.md

doc/source/modules.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
************
2+
Installation
3+
************
4+
5+
Requirements
6+
============
7+
8+
- Python 3.*
9+
- pip 20.0.2
10+
11+
Installing by using PyPi
12+
========================
13+
14+
Install
15+
-------
16+
git clone https://github.com/Intelligent-Systems-Phystech/implicit-reparameterization-trick.git /tmp/implicit-reparameterization-trick
17+
python3 -m pip install /tmp/implicit-reparameterization-trick/src/
18+
19+
Uninstall
20+
---------
21+
python3 -m pip uninstall irt

src/irt/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.0.1'

src/irt/distributions.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import torch
2+
3+
class torch.distributions.Distribution:
4+
'''
5+
The abstract base class for probability distributions, which we inherit from. These methods are implied
6+
to be implemented for each subclass.
7+
'''
8+
def __init__(batch_shape=torch.Size([]), event_shape=torch.Size([])):
9+
'''
10+
Basic constructer of distribution.
11+
'''
12+
13+
@property
14+
def arg_constraints():
15+
'''
16+
Returns a dictionary from argument names to Constraint objects that should
17+
be satisfied by each argument of this distribution. Args that are not tensors need not appear
18+
in this dict.
19+
'''
20+
21+
def cdf(value):
22+
'''
23+
Returns the cumulative density/mass function evaluated at value.
24+
'''
25+
26+
def entropy():
27+
'''
28+
Returns entropy of distribution, batched over batch_shape.
29+
'''
30+
31+
def enumerate_support(expand=True):
32+
'''
33+
Returns tensor containing all values supported by a discrete distribution. The result will
34+
enumerate over dimension 0, so the shape of the result will be (cardinality,) + batch_shape
35+
+ event_shape (where event_shape = () for univariate distributions).
36+
'''
37+
38+
@property
39+
def mean(expand=True):
40+
'''
41+
Returns mean of the distributio.
42+
'''
43+
44+
@property
45+
def mode(expand=True):
46+
'''
47+
Returns mean of the distributio.
48+
'''
49+
def perplexity():
50+
'''
51+
Returns perplexity of distribution, batched over batch_shape.
52+
'''
53+
54+
def rsample(sample_shape=torch.Size([])):
55+
'''
56+
Generates a sample_shape shaped sample or sample_shape shaped batch of samples if the distribution
57+
parameters are batched.
58+
'''
59+
60+
def sample(sample_shape=torch.Size([])):
61+
'''
62+
Generates a sample_shape shaped sample or sample_shape shaped batch of reparameterized samples
63+
if the distribution parameters are batched.
64+
'''
65+
66+
class torch.distributions.implicit.Normal(Distribution):
67+
'''
68+
A Gaussian distribution class with backpropagation capability for the rsample function through IRT.
69+
'''
70+
def __init__(mean_matrix, covariance_matrix=None):
71+
pass
72+
73+
class torch.distributions.implicit.Dirichlet(Distribution):
74+
'''
75+
A Dirichlet distribution class with backpropagation capability for the rsample function through IRT.
76+
'''
77+
def __init__(concentration, validate_args=None):
78+
pass
79+
80+
class torch.distributions.implicit.Mixture(Distribution):
81+
'''
82+
A Mixture of distributions class with backpropagation capability for the rsample function through IRT.
83+
'''
84+
def __init__(distributions : List[Distribution]):
85+
pass
86+
87+
class torch.distributions.implicit.Student(Distribution):
88+
'''
89+
A Student's distribution class with backpropagation capability for the rsample function through IRT.
90+
'''
91+
def __init__():
92+
pass
93+
94+
class torch.distributions.implicit.Factorized(Distribution):
95+
'''
96+
A class for an arbitrary factorized distribution with backpropagation capability for the rsample
97+
function through IRT.
98+
'''

0 commit comments

Comments
 (0)