Skip to content
Merged
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
6 changes: 4 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: flake8

on:
push:
branches:
- main
pull_request:
paths:
- '**.py'
- "**.py"

jobs:
flake8-lint:
Expand All @@ -20,4 +23,3 @@ jobs:

- name: flake8-lint
uses: py-actions/flake8@v2

3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ jobs:
run: |
python -m venv --upgrade-deps .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install .[all]

- name: Run Test
run: |
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Sparse Coding
Reference sparse coding implementations for efficient learning and inference implemented in PyTorch with GPU support.

## Dictionary Learning
Reference sparse coding implementations for efficient learning and inference implemented in PyTorch with GPU support.

## Features

### Dictionary Learning

* Repo currently includes classic patch-wise sparse coding dictionary learning.

## Implemented Inference Methods
### Implemented Inference Methods

* Locally Competative Algorithm (LCA)
* Gradient Descent with Euler's method on Laplace Prior (Vanilla)
* Laplacian Scale Mixture (LSM)
* Iterative Shrinkage-threshold Algorithm (ISTA)
* Generic PyTorch minimization of arbitrary loss function (PyTorchOptimizer)

# Setup
## Setup

1. Clone the repo.
2. Navigate to the directory containing the repo directory.
3. Run `pip install -e sparsecoding`
4. Navigate into the repo and install the requirements using `pip install -r requirements.txt`
5. Install the natural images dataset from this link: https://rctn.org/bruno/sparsenet/IMAGES.mat
6. Try running the demo notebook: `examples/sparse_coding.ipynb`
3. Run `pip install -e ".[all]"`
4. Install the natural images dataset from this link: https://rctn.org/bruno/sparsenet/IMAGES.mat
5. Try running the demo notebook: `examples/sparse_coding.ipynb`

Note: If you are using a Jupyter notebook and change a source file, you can either: 1) restart the Jupyter kernel, or 2) follow instructions [here](https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html#autoreload).

# Contributing
## Contributing

See the [contributing](docs/contributing.md) document!
90 changes: 90 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[project]
name = "sparsecoding"
version = "0.0.1"
# Authors are the current, primary stewards of the repo
# contributors can be found on github
authors = [
{ name = "Alex Belsten", email = "belsten@berkeley.edu" },
{ name = "Christian Shewmake", email = "cshewmake2@gmail.com" },
]
description = "Pytorch infrasctructure for sparse coding."
readme = "README.md"
requires-python = ">=3.8"
# Trove classifiers: https://pypi.org/pypi?%3Aaction=list_classifiers
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Development Status :: 3 - Alpha",
"Natural Language :: English",
]

dependencies = [
"matplotlib",
"numpy",
"scipy",
"torch",
"torchvision",
]


[project.optional-dependencies]
dev = [
"black==24.*",
"coverage",
"ipykernel",
"jupytext",
"nbconvert",
"pylint>=3.3.0",
"pyright",
"pytest",
]

tutorials = [
"jupyter",
"matplotlib",
"tqdm",
"scipy",
]

all = [
"sparsecoding[dev,tutorials]",
]

[project.urls]
"Homepage" = "sparsecoding.readthedocs.io"
"Bug Tracker" = "https://github.com/rctn/sparsecoding/issues"

[build-system]
requires = ["flit_core>=3.2"]
build-backend = "flit_core.buildapi"

[tool.pytest.ini_options]
minversion = "6.0"
addopts = ["--tb=short"]
norecursedirs = ".git examples"
python_files = "*_test.py test_*.py"
log_cli = true
log_cli_level = "INFO"
log_cli_format = "\n%(asctime)s: %(levelname)s: %(filename)s:%(lineno)s::%(module)s::%(funcName)s:\n%(message)s"
log_cli_date_format = "%y-%m-%d %H:%M:%S"

[tool.pylint.format]
max-line-length = "120"

[tool.black]
line-length = 120
extend-exclude = "\\.ipynb"

[tool.pylint]
exclude = [".venv", ".vscode", "docs"]

[tool.pylance]
exclude = [".venv", ".vscode", "docs"]

[tool.pyright]
exclude = [".venv", ".vscode", "docs"]

[tool.isort]
line_length = 120
profile = "black"
3 changes: 0 additions & 3 deletions requirements-dev.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

21 changes: 0 additions & 21 deletions setup.py

This file was deleted.

7 changes: 7 additions & 0 deletions tutorials/vanilla/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Install required dependencies

Install the tutorials dependencies by navigating to the root repo folder and running

```sh
pip install .[tutorials]
```
7 changes: 0 additions & 7 deletions tutorials/vanilla/requirements.txt

This file was deleted.