csnn


Namecsnn JSON
Version 1.0.6 PyPI version JSON
download
home_pageNone
SummaryNeural Networks with CasADi
upload_time2025-02-17 11:56:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords casadi nonlinear-optimization neural-networks
VCS
bugtrack_url
requirements numpy casadi typing_extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Neural Networks with CasADi

**csnn** is a package for creating symbolic neural networks in [CasADi](https://web.casadi.org) in a [PyTorch](https://pytorch.org/)-like API style.

[![PyPI version](https://badge.fury.io/py/csnn.svg)](https://badge.fury.io/py/csnn)
[![Source Code License](https://img.shields.io/badge/license-MIT-blueviolet)](https://github.com/FilippoAiraldi/casadi-neural-nets/blob/master/LICENSE)
![Python 3.9](https://img.shields.io/badge/python->=3.9-green.svg)

[![Tests](https://github.com/FilippoAiraldi/casadi-neural-nets/actions/workflows/ci.yml/badge.svg)](https://github.com/FilippoAiraldi/casadi-neural-nets/actions/workflows/ci.yml)
[![Downloads](https://static.pepy.tech/badge/csnn)](https://www.pepy.tech/projects/csnn)
[![Maintainability](https://api.codeclimate.com/v1/badges/6006c41542cd8e902125/maintainability)](https://codeclimate.com/github/FilippoAiraldi/casadi-neural-nets/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/6006c41542cd8e902125/test_coverage)](https://codeclimate.com/github/FilippoAiraldi/casadi-neural-nets/test_coverage)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

---

## Introduction

The package allows the creation of neural networks with the symbolic language offered by [CasADi](https://web.casadi.org). This is done in a similar way to [PyTorch](https://pytorch.org/). For example, the following code allows us to create an MLP with a hidden layer:

```python
import casadi as cs
from csnn import set_sym_type, Linear, Sequential, ReLU

set_sym_type("SX")  # can set either MX or SX

net = Sequential[cs.SX]((
    Linear(4, 32),
    ReLU(),
    Linear(32, 1),
    ReLU()
))

batch = 2
input = cs.SX.sym("in", batch, 4)
output = net(input)
assert output.shape == (batch, 1)
```

---

## Implemented Modules

So far, the following modules that are available in PyTorch have been implemented:

- Containers
  * Module
  * Sequential
- Activation functions
  * GELU
  * SELU
  * LeakyReLU
  * ReLU
  * Sigmoid
  * Softplus
  * Tanh
- Linear layers
  * Linear
- Recurrent layers
  * RNNCell
  * RNN
- Dropout layers
  * Dropout
  * Dropout1d

Additionally, the library provides the implementation for the following convex neural networks (see `csnn.convex`):

- FicNN
- PwqNN
- PsdNN

---

## Installation

To install the package, run

```bash
pip install csnn
```

**csnn** has the following dependencies

- [CasADi](https://web.casadi.org)

For playing around with the source code instead, run

```bash
git clone https://github.com/FilippoAiraldi/casadi-neural-nets.git
```

---

## License

The repository is provided under the MIT License. See the LICENSE file included with this repository.

---

## Author

[Filippo Airaldi](https://www.tudelft.nl/staff/f.airaldi/), PhD Candidate [f.airaldi@tudelft.nl | filippoairaldi@gmail.com]

> [Delft Center for Systems and Control](https://www.tudelft.nl/en/3me/about/departments/delft-center-for-systems-and-control/) in [Delft University of Technology](https://www.tudelft.nl/en/)

Copyright (c) 2023 Filippo Airaldi.

Copyright notice: Technische Universiteit Delft hereby disclaims all copyright interest in the program “csnn” (Nueral Networks with CasADi) written by the Author(s). Prof. Dr. Ir. Fred van Keulen, Dean of 3mE.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "csnn",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "casadi, nonlinear-optimization, neural-networks",
    "author": null,
    "author_email": "Filippo Airaldi <filippoairaldi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fc/bd/5b513c463659aea6ae3af46fdbe030e537b0ee54e9096a877b92063d9ec7/csnn-1.0.6.tar.gz",
    "platform": null,
    "description": "# Neural Networks with CasADi\r\n\r\n**csnn** is a package for creating symbolic neural networks in [CasADi](https://web.casadi.org) in a [PyTorch](https://pytorch.org/)-like API style.\r\n\r\n[![PyPI version](https://badge.fury.io/py/csnn.svg)](https://badge.fury.io/py/csnn)\r\n[![Source Code License](https://img.shields.io/badge/license-MIT-blueviolet)](https://github.com/FilippoAiraldi/casadi-neural-nets/blob/master/LICENSE)\r\n![Python 3.9](https://img.shields.io/badge/python->=3.9-green.svg)\r\n\r\n[![Tests](https://github.com/FilippoAiraldi/casadi-neural-nets/actions/workflows/ci.yml/badge.svg)](https://github.com/FilippoAiraldi/casadi-neural-nets/actions/workflows/ci.yml)\r\n[![Downloads](https://static.pepy.tech/badge/csnn)](https://www.pepy.tech/projects/csnn)\r\n[![Maintainability](https://api.codeclimate.com/v1/badges/6006c41542cd8e902125/maintainability)](https://codeclimate.com/github/FilippoAiraldi/casadi-neural-nets/maintainability)\r\n[![Test Coverage](https://api.codeclimate.com/v1/badges/6006c41542cd8e902125/test_coverage)](https://codeclimate.com/github/FilippoAiraldi/casadi-neural-nets/test_coverage)\r\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\r\n\r\n---\r\n\r\n## Introduction\r\n\r\nThe package allows the creation of neural networks with the symbolic language offered by [CasADi](https://web.casadi.org). This is done in a similar way to [PyTorch](https://pytorch.org/). For example, the following code allows us to create an MLP with a hidden layer:\r\n\r\n```python\r\nimport casadi as cs\r\nfrom csnn import set_sym_type, Linear, Sequential, ReLU\r\n\r\nset_sym_type(\"SX\")  # can set either MX or SX\r\n\r\nnet = Sequential[cs.SX]((\r\n    Linear(4, 32),\r\n    ReLU(),\r\n    Linear(32, 1),\r\n    ReLU()\r\n))\r\n\r\nbatch = 2\r\ninput = cs.SX.sym(\"in\", batch, 4)\r\noutput = net(input)\r\nassert output.shape == (batch, 1)\r\n```\r\n\r\n---\r\n\r\n## Implemented Modules\r\n\r\nSo far, the following modules that are available in PyTorch have been implemented:\r\n\r\n- Containers\r\n  * Module\r\n  * Sequential\r\n- Activation functions\r\n  * GELU\r\n  * SELU\r\n  * LeakyReLU\r\n  * ReLU\r\n  * Sigmoid\r\n  * Softplus\r\n  * Tanh\r\n- Linear layers\r\n  * Linear\r\n- Recurrent layers\r\n  * RNNCell\r\n  * RNN\r\n- Dropout layers\r\n  * Dropout\r\n  * Dropout1d\r\n\r\nAdditionally, the library provides the implementation for the following convex neural networks (see `csnn.convex`):\r\n\r\n- FicNN\r\n- PwqNN\r\n- PsdNN\r\n\r\n---\r\n\r\n## Installation\r\n\r\nTo install the package, run\r\n\r\n```bash\r\npip install csnn\r\n```\r\n\r\n**csnn** has the following dependencies\r\n\r\n- [CasADi](https://web.casadi.org)\r\n\r\nFor playing around with the source code instead, run\r\n\r\n```bash\r\ngit clone https://github.com/FilippoAiraldi/casadi-neural-nets.git\r\n```\r\n\r\n---\r\n\r\n## License\r\n\r\nThe repository is provided under the MIT License. See the LICENSE file included with this repository.\r\n\r\n---\r\n\r\n## Author\r\n\r\n[Filippo Airaldi](https://www.tudelft.nl/staff/f.airaldi/), PhD Candidate [f.airaldi@tudelft.nl | filippoairaldi@gmail.com]\r\n\r\n> [Delft Center for Systems and Control](https://www.tudelft.nl/en/3me/about/departments/delft-center-for-systems-and-control/) in [Delft University of Technology](https://www.tudelft.nl/en/)\r\n\r\nCopyright (c) 2023 Filippo Airaldi.\r\n\r\nCopyright notice: Technische Universiteit Delft hereby disclaims all copyright interest in the program \u201ccsnn\u201d (Nueral Networks with CasADi) written by the Author(s). Prof. Dr. Ir. Fred van Keulen, Dean of 3mE.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Neural Networks with CasADi",
    "version": "1.0.6",
    "project_urls": {
        "Bug Tracker": "https://github.com/FilippoAiraldi/casadi-neural-nets/issues",
        "Homepage": "https://github.com/FilippoAiraldi/casadi-neural-nets"
    },
    "split_keywords": [
        "casadi",
        " nonlinear-optimization",
        " neural-networks"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b5f3cb99e12540a7a0f6ce255a123ea715da5294a6b2278f648da50f05412947",
                "md5": "0f66e7f2ba492b3d7b3485679af02832",
                "sha256": "2b21046e7538545d3fc78958a5df60639c2751962b22e5035862b58bfbe99e07"
            },
            "downloads": -1,
            "filename": "csnn-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0f66e7f2ba492b3d7b3485679af02832",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 23657,
            "upload_time": "2025-02-17T11:56:31",
            "upload_time_iso_8601": "2025-02-17T11:56:31.875443Z",
            "url": "https://files.pythonhosted.org/packages/b5/f3/cb99e12540a7a0f6ce255a123ea715da5294a6b2278f648da50f05412947/csnn-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fcbd5b513c463659aea6ae3af46fdbe030e537b0ee54e9096a877b92063d9ec7",
                "md5": "5b417c0a6d1fc0e6fda24a7e06c9a351",
                "sha256": "6d1a32cfe9d7682d2891e0a7185f1f8d1cce78fc99d12866df47406f7fa733ec"
            },
            "downloads": -1,
            "filename": "csnn-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "5b417c0a6d1fc0e6fda24a7e06c9a351",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 23523,
            "upload_time": "2025-02-17T11:56:33",
            "upload_time_iso_8601": "2025-02-17T11:56:33.150317Z",
            "url": "https://files.pythonhosted.org/packages/fc/bd/5b513c463659aea6ae3af46fdbe030e537b0ee54e9096a877b92063d9ec7/csnn-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-17 11:56:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FilippoAiraldi",
    "github_project": "casadi-neural-nets",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.24.2"
                ]
            ]
        },
        {
            "name": "casadi",
            "specs": [
                [
                    ">=",
                    "3.6.3"
                ]
            ]
        },
        {
            "name": "typing_extensions",
            "specs": [
                [
                    ">=",
                    "4.6.0"
                ]
            ]
        }
    ],
    "lcname": "csnn"
}
        
Elapsed time: 0.44687s