Skip to content

Commit 40e4131

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 8c4a94e + 4fb7e01 commit 40e4131

34 files changed

+1023
-1897
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
patreon: thegeophysicist
1+
custom: https://dramsch.net

.github/workflows/codeql.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "main" ]
20+
schedule:
21+
- cron: '27 20 * * 0'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'python' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v3
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
52+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53+
# queries: security-extended,security-and-quality
54+
55+
56+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
57+
# If this step fails, then you should remove it and run the build manually (see below)
58+
- name: Autobuild
59+
uses: github/codeql-action/autobuild@v2
60+
61+
# ℹ️ Command-line programs to run using the OS shell.
62+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63+
64+
# If the Autobuild fails above, remove it and uncomment the following three lines.
65+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66+
67+
# - run: |
68+
# echo "Run, Build Application using script"
69+
# ./location_of_script_within_repo/buildscript.sh
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v2
73+
with:
74+
category: "/language:${{matrix.language}}"

.github/workflows/publish.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish to PyPI.org
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: [published]
6+
jobs:
7+
pypi:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
- run: python3 -m pip install --upgrade build && python3 -m build
15+
- name: Publish package
16+
uses: pypa/gh-action-pypi-publish@release/v1
17+
with:
18+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test_python.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test Python package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: ["3.8", "3.9", "3.10"]
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install flake8 pytest
23+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
24+
- name: Lint with flake8
25+
run: |
26+
# stop the build if there are Python syntax errors or undefined names
27+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
28+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
29+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
30+
- name: Test with pytest
31+
run: |
32+
pytest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ build/
4141
venv
4242

4343
.vscode
44+
45+
dist/*
46+
47+
__pycache__/*

.readthedocs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-20.04
11+
tools:
12+
python: "3.10"
13+
# You can also specify other tool versions:
14+
# nodejs: "16"
15+
# rust: "1.55"
16+
# golang: "1.17"
17+
18+
# Build documentation in the docs/ directory with Sphinx
19+
sphinx:
20+
configuration: docs/source/conf.py
21+
22+
# If using Sphinx, optionally build your docs in additional formats such as PDF
23+
formats:
24+
- pdf
25+
26+
python:
27+
install:
28+
- requirements: docs/requirements.txt

.travis.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

README.md

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# Complex-Valued Neural Networks in Keras with Tensorflow
2-
[![Documentation](https://readthedocs.org/projects/keras-complex/badge/?version=latest)](https://keras-complex.readthedocs.io/) [![PyPI Status](https://img.shields.io/pypi/status/keras-complex.svg)](https://pypi.python.org/pypi/keras-complex) [![PyPI Versions](https://img.shields.io/pypi/pyversions/keras-complex.svg)](https://pypi.python.org/pypi/keras-complex) [![Build Status](https://travis-ci.org/JesperDramsch/keras-complex.svg?branch=master)](https://travis-ci.org/JesperDramsch/keras-complex) [![PyPI License](https://img.shields.io/pypi/l/keras-complex.svg)](LICENSCE.md)
3-
4-
5-
6-
7-
8-
2+
[![Documentation](https://readthedocs.org/projects/keras-complex/badge/?version=latest)](https://keras-complex.readthedocs.io/) [![Build Status](https://github.com/JesperDramsch/keras-complex/actions/workflows/test_python.yml/badge.svg)](https://github.com/JesperDramsch/keras-complex/actions/) [![PyPI Versions](https://img.shields.io/pypi/pyversions/keras-complex.svg)](https://pypi.python.org/pypi/keras-complex) ![Tensorflow 2+](https://img.shields.io/badge/tensorflow-%3E2.0-orange) ![PyPI - Downloads](https://img.shields.io/pypi/dm/keras-complex) [![PyPI Status](https://img.shields.io/pypi/status/keras-complex.svg)](https://pypi.python.org/pypi/keras-complex) [![PyPI License](https://img.shields.io/badge/License-MIT-green)](LICENSCE.md)
93

104
[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.
115

@@ -17,20 +11,15 @@ Requirements
1711
- numpy
1812
- scipy
1913
- scikit-learn
20-
- keras
21-
- tensorflow 1.X or tensorflow-gpu 1.X
14+
- tensorflow 2.X
2215

2316
Install requirements for computer vision experiments with pip:
24-
```
25-
pip install -f requirements.txt
26-
```
2717

28-
For the non-gpu version:
2918
```
30-
pip install -f requirements-nogpu.txt
19+
pip install -r requirements.txt
3120
```
3221

33-
Depending on your Python installation you might want to use anaconda or other tools.
22+
Depending on your Python installation you might want to use anaconda or venv or other tools.
3423

3524

3625
Installation
@@ -39,16 +28,12 @@ Installation
3928
```
4029
pip install keras-complex
4130
```
42-
and
43-
```
44-
pip install tensorflow-gpu
45-
```
4631

4732
Usage
4833
-----
4934
Build your neural networks with the help of keras.
5035

51-
```python
36+
```
5237
import complexnn
5338
5439
import keras
@@ -68,21 +53,28 @@ model.compile(optimizer=optimizers.Adam(), loss='mse')
6853

6954
An example working implementation of an autoencoder can be found [here](https://github.com/JesperDramsch/Complex-CNN-Seismic/).
7055

71-
Citation
72-
--------
56+
Complex Format of Tensors
57+
-------------------------
7358

74-
Please cite the original work as:
59+
This library assumes that complex values are split into two real-valued parts. The real-valued and complex-valued complement, also seen [in the Docs](https://keras-complex.readthedocs.io/math.html).
60+
61+
The tensors for a 2D complex tensor of 3x3, the look like:
7562

7663
```
77-
@ARTICLE {Trabelsi2017,
78-
author = "Chiheb Trabelsi, Olexa Bilaniuk, Ying Zhang, Dmitriy Serdyuk, Sandeep Subramanian, João Felipe Santos, Soroush Mehri, Negar Rostamzadeh, Yoshua Bengio, Christopher J Pal",
79-
title = "Deep Complex Networks",
80-
journal = "arXiv preprint arXiv:1705.09792",
81-
year = "2017"
82-
}
64+
[[[r r r],
65+
[r r r],
66+
[r r r]],
67+
[i,i,i],
68+
[i,i,i],
69+
[i,i,i]]]
8370
```
8471

85-
Cite this software version as:
72+
So multiple samples should then be arranged into `[r,r,r,i,i,i]`, which is also documented [in the Docs](https://keras-complex.readthedocs.io/math.html#implementation).
73+
74+
Citation
75+
--------
76+
77+
Find the [CITATION file](/CITATION.cff) or cite this software version as:
8678
```
8779
@misc{dramsch2019complex,
8880
title = {Complex-Valued Neural Networks in Keras with Tensorflow},
@@ -93,3 +85,14 @@ Cite this software version as:
9385
year = {2019}
9486
}
9587
```
88+
89+
Please cite the original work as:
90+
91+
```
92+
@ARTICLE {Trabelsi2017,
93+
author = "Chiheb Trabelsi, Olexa Bilaniuk, Ying Zhang, Dmitriy Serdyuk, Sandeep Subramanian, João Felipe Santos, Soroush Mehri, Negar Rostamzadeh, Yoshua Bengio, Christopher J Pal",
94+
title = "Deep Complex Networks",
95+
journal = "arXiv preprint arXiv:1705.09792",
96+
year = "2017"
97+
}
98+
```

complexnn/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
#
5-
# Authors: Olexa Bilaniuk
6-
#
7-
# What this module includes by default:
84
from . import bn, conv, dense, init, norm, pool
5+
96
# from . import fft
107

118
from .bn import ComplexBatchNormalization as ComplexBN
@@ -17,6 +14,7 @@
1714
WeightNorm_Conv,
1815
)
1916
from .dense import ComplexDense
17+
2018
# from .fft import (fft, ifft, fft2, ifft2, FFT, IFFT, FFT2, IFFT2)
2119
from .init import (
2220
ComplexIndependentFilters,

0 commit comments

Comments
 (0)