Skip to content

Commit 8140778

Browse files
committed
initial commit
1 parent 81264e4 commit 8140778

File tree

7 files changed

+195
-0
lines changed

7 files changed

+195
-0
lines changed

.gitignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
.idea
106+
.idea/

LICENSE.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
MIT License
2+
Copyright (c) 2018 YOUR NAME
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
The above copyright notice and this permission notice shall be included in all
10+
copies or substantial portions of the Software.
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# ComplexCNN
22
pytorch implementation of complex convolutional neural network
3+
Reference: [https://arxiv.org/pdf/1705.09792.pdf](https://arxiv.org/pdf/1705.09792.pdf)
4+
5+
## Usage

__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+

modules.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
import torch
3+
import torch.nn as nn
4+
import numpy as np
5+
6+
class ComplexConv(nn.Module):
7+
def __init__(self, in_channel, out_channel, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True):
8+
super(ComplexConv,self).__init__()
9+
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
10+
self.padding = padding
11+
12+
## Model components
13+
self.conv_re = nn.Conv2d(in_channel, out_channel, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)
14+
self.conv_im = nn.Conv2d(in_channel, out_channel, kernel_size, stride=stride, padding=padding, dilation=dilation, groups=groups, bias=bias)
15+
16+
def forward(self, x): # shpae of x : [batch,2,channel,axis1,axis2]
17+
real = self.conv_re(x[:,0]) - self.conv_im(x[:,1])
18+
imaginary = self.conv_re(x[:,1]) + self.conv_im(x[:,0])
19+
output = torch.stack((real,imaginary),dim=1)
20+
return output
21+
22+
#%%
23+
if __name__ == "__main__":
24+
## Random Tensor for Input
25+
## shape : [batchsize,2,channel,axis1_size,axis2_size]
26+
## Below dimensions are totally random
27+
x = torch.randn((10,2,3,100,100))
28+
29+
# 1. Make ComplexConv Object
30+
## (in_channel, out_channel, kernel_size) parameter is required
31+
complexConv = ComplexConv(3,10,(5,5))
32+
33+
# 2. compute
34+
y = complexConv(x)
35+

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Inside of setup.cfg
2+
[metadata]
3+
description-file = README.md

setup.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from distutils.core import setup
4+
setup(
5+
name = 'complexcnn', # How you named your package folder (MyLib)
6+
packages = ['complexcnn'], # Chose the same as "name"
7+
version = '0.1', # Start with a small number and increase it with every change you make
8+
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
9+
description = 'pytorch implementation of complex convolutional neural network', # Give a short description about your library
10+
author = 'James Yougchae Chee', # Type in your name
11+
author_email = '[email protected]', # Type in your E-Mail
12+
url = 'https://github.com/litcoderr/ComplexCNN', # Provide either the link to your github or to your website
13+
download_url = 'https://github.com/litcoderr/ComplexCNN/archive/v_0.1.tar.gz', # I explain this later on
14+
keywords = ['deeplearning', 'pytorch', 'machinelearning'], # Keywords that define your package best
15+
install_requires=[ # I get to this in a second
16+
'pytorch',
17+
'numpy',
18+
],
19+
classifiers=[
20+
'Development Status :: 3 - Alpha', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
21+
'Intended Audience :: Developers', # Define that your audience are developers
22+
'Topic :: Software Development :: Build Tools',
23+
'License :: OSI Approved :: MIT License', # Again, pick a license
24+
'Programming Language :: Python :: 3', #Specify which pyhton versions that you want to support
25+
'Programming Language :: Python :: 3.4',
26+
'Programming Language :: Python :: 3.5',
27+
'Programming Language :: Python :: 3.6',
28+
],
29+
)

0 commit comments

Comments
 (0)