Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Repository files navigation

PyPI version

keras-spconn

Sparse Connectivity Recurrent Neural Networks

Installation

The keras-spconn git repo is available as PyPi package

pip install keras-spconn
pip install git+ssh://git@github.com/kmedian/keras-spconn.git

Usage

Check the examples folder for notebooks.

Appendix

Install a virtual environment for CPU

python3 -m venv .venv
source .venv/bin/activate
pip3 install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
pip3 install -r requirements-demo.txt
# reinstall TF for better Intel-CPU support
# pip install intel-tensorflow

(If your git repo is stored in a folder with whitespaces, then don't use the subfolder .venv. Use an absolute path without whitespaces.)

Install MiniConda for GPU

Please note that using GPUs for tensorflow.sparse is not adding speed improvements because most tensorflow.sparse functions only support CPU, i.e., the program would switch between GPU and CPU memory all the time what is very slow.

TensorFlow needs the CUDA drivers that available as Python packages only via Conda (Nvidia does not maintain PyPi packages).

conda install pip
conda create --name gpu-venv-keras-spconn python=3.9 pip
conda activate gpu-venv-keras-spconn
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
pip install -r requirements.txt
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/

Install MiniConda if not exists

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# prevent conda autostart in shell
# conda config --set auto_activate_base false

Python commands

  • Jupyter for the examples: jupyter lab
  • Check syntax: flake8 --ignore=F401 --exclude=$(grep -v '^#' .gitignore | xargs | sed -e 's/ /,/g')
  • Unit testing: pytest

Publish

pandoc README.md --from markdown --to rst -s -o README.rst
python setup.py sdist 
twine upload -r pypi dist/*

Clean up

find . -type f -name "*.pyc" | xargs rm
find . -type d -name "__pycache__" | xargs rm -r
rm -r .pytest_cache
rm -r .venv

Support

Please open an issue for support.

License and citation

  • This package depends on the python package sparsity-pattern what is used to generate sparse matrices. If you would like to cite the sparsity-pattern package, please use DOI: 10.5281/zenodo.4357290

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

Releases

Sponsor this project

Packages

Contributors

Languages