diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b656d5e..b57ccc0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,18 +1,24 @@ name: Publish to PyPI.org + +# Publishing a GitHub release is the only way to upload to PyPI. on: - workflow_dispatch: release: types: [published] + jobs: pypi: runs-on: ubuntu-latest + # Must match the environment in the PyPI trusted publisher settings. + environment: PyPI + permissions: + # Trusted publishing: PyPI accepts this job's OIDC token instead of an API token. + id-token: write steps: - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@v7 with: + # setuptools-scm needs the tags to compute the version. fetch-depth: 0 - - run: python3 -m pip install --upgrade build && python3 -m build + - uses: astral-sh/setup-uv@v10.3.0 + - run: uv build - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index a2ce989..03fafcd 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -16,6 +16,27 @@ jobs: # Stop on syntax errors and undefined names only. - run: uvx flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # 0.2.3 shipped invalid metadata that pip 24.1 and later refuse to install. + # Build the package and install it the way users do before any release. + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - uses: astral-sh/setup-uv@v10.3.0 + with: + python-version: "3.12" + activate-environment: true + - run: uv build + - name: Check metadata + run: uvx twine check --strict dist/* + - name: Install the wheel with current pip + run: | + uv pip install "pip>=24.1" + python -m pip install dist/*.whl + python -c "import complexnn" + test: name: ${{ matrix.name }} runs-on: ubuntu-latest diff --git a/CITATION.cff b/CITATION.cff index 95e0f17..1ed617e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -3,7 +3,7 @@ message: 'Please cite the following works when using this software.' authors: - family-names: 'Dramsch' given-names: 'Jesper Sören' - orcid: '0000-0001-8273-905X' + orcid: 'https://orcid.org/0000-0001-8273-905X' doi: '10.6084/m9.figshare.9783773' identifiers: - type: 'doi' @@ -12,32 +12,37 @@ identifiers: value: 'https://figshare.com/articles/Complex-Valued_Neural_Networks_in_Keras_with_Tensorflow/9783773/1' title: 'Complex-Valued Neural Networks in Keras with Tensorflow' url: 'https://figshare.com/articles/Complex-Valued_Neural_Networks_in_Keras_with_Tensorflow/9783773/1' -date-published: 2019-01-01 -year: 2019 -publisher: - name: 'figshare' +repository-code: 'https://github.com/JesperDramsch/keras-complex' +license: 'MIT' type: 'software' preferred-citation: + type: 'article' abstract: 'Deep learning has become an area of interest in most scientific areas, including physical sciences. Modern networks apply real-valued transformations on the data. Particularly, convolutions in convolutional neural networks discard phase information entirely. Many deterministic signals, such as seismic data or electrical signals, contain significant information in the phase of the signal. We explore complex-valued deep convolutional networks to leverage non-linear feature maps. Seismic data commonly has a lowcut filter applied, to attenuate noise from ocean waves and similar long wavelength contributions. In non-stationary data, the phase content can stabilize training and improve the generalizability of neural networks. While it has been shown that phase content can be restored in deep neural networks, we show how including phase information in feature maps improves both training and inference from deterministic physical data. Furthermore, we show that smaller complex networks outperform larger real-valued networks.' authors: - family-names: 'Dramsch' given-names: 'Jesper Sören' - orcid: '0000-0001-8273-905X' + orcid: 'https://orcid.org/0000-0001-8273-905X' - family-names: 'Lüthje' given-names: 'Mikael' - orcid: "0000-0003-2715-1653" + orcid: 'https://orcid.org/0000-0003-2715-1653' - family-names: 'Christensen' given-names: 'Anders Nymark' - orcid: "0000-0002-3668-3128" - doi: 'https://doi.org/10.1016/j.cageo.2020.104643' + orcid: 'https://orcid.org/0000-0002-3668-3128' + title: 'Complex-valued neural networks for machine learning on non-stationary physical data' + journal: 'Computers & Geosciences' + volume: 146 + start: 104643 + year: 2021 + month: 1 + publisher: + name: 'Elsevier BV' + issn: '0098-3004' + doi: '10.1016/j.cageo.2020.104643' identifiers: - type: 'doi' - value: 'https://doi.org/10.1016/j.cageo.2020.104643' + value: '10.1016/j.cageo.2020.104643' - type: 'url' value: 'https://www.sciencedirect.com/science/article/pii/S0098300420306208' - - type: 'other' - value: 'urn:issn:0098-3004' - title: 'Complex-valued neural networks for machine learning on non-stationary physical data' url: 'https://www.sciencedirect.com/science/article/pii/S0098300420306208' references: - authors: diff --git a/README.md b/README.md index ac6117f..eb32873 100644 --- a/README.md +++ b/README.md @@ -3,35 +3,23 @@ ## Status -keras-complex is being updated for Keras 3. The current release, 0.2.3, does not work with TensorFlow 2.16 or later, because TensorFlow now ships Keras 3 (see [#23](https://github.com/JesperDramsch/keras-complex/issues/23)). Its package metadata is also invalid, so pip 24.1 and later skip it and install the older 0.1.3 instead. Version 0.3.0 will fix both. +keras-complex works with current TensorFlow and Keras 3. It is maintained as time allows: it gets fixes when TensorFlow or Keras change, and issues and pull requests are welcome. New features are not planned. -Until then, install from GitHub and use TensorFlow 2.15, or keep a newer TensorFlow and add `tf-keras`: +CI tests every change against the latest TensorFlow with Keras 3 on Python 3.11 to 3.13, and against Keras 2 through TensorFlow 2.15 and through `tf-keras`. -``` -pip install "git+https://github.com/JesperDramsch/keras-complex" tf-keras -``` - -With `tf-keras`, set `TF_USE_LEGACY_KERAS=1` before TensorFlow is first imported. +Not working in this release: spectral pooling, `spectral_parametrization=True`, `WeightNorm_Conv`, `SqrtInit`, the `fft` module, and training `ComplexConv1D` with `transposed=True`. They fail on Keras 2 as well, so they were already broken before the Keras 3 update. [Complex-valued convolutions](https://en.wikipedia.org/wiki/Convolution#Domain_of_definition) could provide some interesting results in signal processing-based deep learning. A simple(-ish) idea is including explicit phase information of time series in neural networks. This code enables complex-valued convolution in convolutional neural networks in [keras](https://keras.io) with the [TensorFlow](https://tensorflow.org/) backend. This makes the network modular and interoperable with standard keras layers and operations. -This code is very much in **Alpha**. Please consider helping out improving the code to advance together. This repository is based on the code which reproduces experiments presented in the paper [Deep Complex Networks](https://arxiv.org/abs/1705.09792). It is a port to Keras with Tensorflow-backend. +This repository is based on the code which reproduces experiments presented in the paper [Deep Complex Networks](https://arxiv.org/abs/1705.09792). It is a port to Keras with Tensorflow-backend. Requirements ------------ -- numpy -- scipy -- scikit-learn -- tensorflow 2.X - -Install requirements for computer vision experiments with pip: - -``` -pip install -r requirements.txt -``` +- Python 3.11 or later +- TensorFlow 2.15 or later -Depending on your Python installation you might want to use anaconda or venv or other tools. +Keras 3 (TensorFlow 2.16 and later) and Keras 2 both work. To use Keras 2 with a newer TensorFlow, install `tf-keras` and set `TF_USE_LEGACY_KERAS=1` before TensorFlow is first imported. Installation diff --git a/pyproject.toml b/pyproject.toml index 6c5846b..c55850e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,8 @@ maintainers = [ {name = "Jesper Dramsch", email = "jesper@dramsch.net"} ] description = "Complex values in Keras" -requires-python = ">=3.8" +requires-python = ">=3.11" +readme = "README.md" keywords = ["Machine Learning", "Deep Learning", "Complex Numbers", "Keras", "TensorFlow"] license = {file = "LICENSE.md"} classifiers = [ @@ -20,9 +21,9 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Scientific/Engineering :: Artificial Intelligence", @@ -31,10 +32,8 @@ classifiers = [ "Natural Language :: English", ] dependencies = [ - 'tensorflow>=2.0.0', + 'tensorflow>=2.15', 'numpy', - 'scipy', - 'scikit-learn', ] dynamic = ["version"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 31a6c3b..0000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -numpy -scikit-learn -scipy -tensorflow \ No newline at end of file