Metadata-Version: 2.4
Name: swimnetworks
Version: 0.0.2
Summary: SWIM training of neural networks.
Author: Erik Bolager, Iryna Burak, Chinmay Datar, Qing Sun
Author-email: Felix Dietrich <felix.dietrich@tum.de>
License-Expression: MIT
Project-URL: Homepage, https://gitlab.com/fd-research/swimnetworks
Project-URL: Bug Tracker, https://gitlab.com/fd-research/swimnetworks/-/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
License-File: CONTRIBUTORS
Requires-Dist: numpy>=1.23.5
Requires-Dist: scikit-learn>=1.2.2
Dynamic: license-file

SWIM: sample where it matters!
*************************************

``swimnetworks`` implements the algorithm SWIM for sampling weights of neural networks.
The algorithm provides a way to quickly train neural networks on a CPU.
For more details on the theoretical background of the method, refer to our paper [1]_.

The package documentation can be found at https://fd-research.gitlab.io/swimnetworks/.

Installation
==============

To install the main package with the requirements, one needs to clone the repository and execute the following command from the root folder:

.. code-block:: bash

    pip install .

Example
==============

Here is a small example of defining a sampled network:

.. code-block:: python

    from sklearn.pipeline import Pipeline
    from swimnetworks import Dense, Linear

    steps = [
        ("dense", Dense(layer_width=512, activation="tanh",
                         parameter_sampler="tanh",
                         random_seed=42)),
        ("linear", Linear(regularization_scale=1e-10))
    ]
    model = Pipeline(steps)

Then, one can use :code:`model.fit(X_train, y_train)` and :code:`model.transform(X_test)` to train and evaluate the model.
The numerical experiments from [1]_ can be found in a separate `repository`_.

Running Tests
===============

.. image:: https://gitlab.com/fd-research/swimnetworks/-/jobs/artifacts/main/raw/coverage.svg?job=coverage-report
    :alt: coverage

Run all the tests using:

.. code-block:: bash

    python3 -m unittest tests/*.py

You can test coverage after installing ``coverage`` (e.g., using pip):

.. code-block:: bash

    pip install coverage

Then run:

.. code-block:: bash

    coverage run -m unittest discover
    coverage report

Citation
==========

If you use the SWIM package in your research, please cite the following `paper`_:

.. [1] E\. Bolager, I. Burak, C. Datar, Q. Sun, F. Dietrich. Sampling weights of deep neural networks. arXiv:2306.16830, 2023.

.. _paper: https://arxiv.org/abs/2306.16830

.. _repository: https://gitlab.com/felix.dietrich/swimnetworks-paper
