Skip to content

Commit 577931d

Browse files
author
Parag K. Mital
committed
first commit
1 parent 655bef0 commit 577931d

File tree

134 files changed

+17663
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+17663
-0
lines changed

.gitignore

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*.cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
local_settings.py
55+
56+
# Flask stuff:
57+
instance/
58+
.webassets-cache
59+
60+
# Scrapy stuff:
61+
.scrapy
62+
63+
# Sphinx documentation
64+
docs/_build/
65+
66+
# PyBuilder
67+
target/
68+
69+
# Jupyter Notebook
70+
.ipynb_checkpoints
71+
72+
# pyenv
73+
.python-version
74+
75+
# celery beat schedule file
76+
celerybeat-schedule
77+
78+
# SageMath parsed files
79+
*.sage.py
80+
81+
# Environments
82+
.env
83+
.venv
84+
env/
85+
venv/
86+
ENV/
87+
88+
# Spyder project settings
89+
.spyderproject
90+
.spyproject
91+
92+
# Rope project settings
93+
.ropeproject
94+
95+
# mkdocs documentation
96+
/site
97+
98+
# mypy
99+
.mypy_cache/

HISTORY.md

Whitespace-only changes.

LICENSE.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016 Parag K. Mital
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

MANIFEST.in

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include HISTORY.md
2+
include README.md
3+
include NOTICE.md
4+
include setup.py
5+
include tox.ini
6+
include conftest.py
7+
8+
graft docs
9+
10+
exclude docs/_build
11+
recursive-exclude * __pycache__
12+
recursive-exclude * *.py[co]

NOTICE.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This code is part of the Kadenze Academy program on "Creative Applications of Deep Learning with Tensorflow" taught by Parag K. Mital. More information can be found on the course website: https://www.kadenze.com/programs/creative-applications-of-deep-learning-with-tensorflow and the course github: https://github.com/pkmital/CADL. This code is licensed under the APL 2.0 by Parag K. Mital and this entire notice should appear at the top of any reproductions of the code contained in this repository.

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Introduction
2+
3+
This package is part of the Kadenze Academy program [Creative Applications of Deep Learning w/ TensorFlow](https://www.kadenze.com/programs/creative-applications-of-deep-learning-with-tensorflow).
4+
5+
# Contents
6+
7+
This package contains various models, architectures, and building blocks covered in the Kadenze Academy program including:
8+
9+
* Autoencoders
10+
* Character Level Recurrent Neural Network (CharRNN)
11+
* Conditional Pixel CNN
12+
* CycleGAN
13+
* Deep Convolutional Generative Adversarial Networks (DCGAN)
14+
* Deep Dream
15+
* Deep Recurrent Attentive Writer (DRAW)
16+
* Gated Convolution
17+
* Generative Adversarial Networks (GAN)
18+
* Global Vector Embeddings (GloVe)
19+
* Illustration2Vec
20+
* Inception
21+
* Mixture Density Networks (MDN)
22+
* PixelCNN
23+
* NSynth
24+
* Residual Networks
25+
* Sequence2Seqeuence (Seq2Seq) w/ Attention (both bucketed and dynamic rnn variants available)
26+
* Style Net
27+
* Variational Autoencoders (VAE)
28+
* Variational Autoencoding Generative Adversarial Networks (VAEGAN)
29+
* Video Style Net
30+
* VGG16
31+
* WaveNet / Fast WaveNet Generation w/ Queues / WaveNet Autoencoder (NSynth)
32+
* Word2Vec
33+
34+
and more. It also includes various datasets, preprocessing, batch generators, input pipelines, and plenty more for datasets such as:
35+
36+
* CELEB
37+
* CIFAR
38+
* Cornell
39+
* MNIST
40+
* TedLium
41+
* LibriSpeech
42+
* VCTK
43+
44+
and plenty of utilities for working with images, GIFs, sound (wave) files, MIDI, video, text, TensorFlow, TensorBoard, and their graphs.
45+
46+
Examples of each module's use can be found in the tests folder.
47+
48+
# Contributing
49+
50+
Contributions, such as other model architectures, bug fixes, dataset handling, etc... are welcome and should be filed on the GitHub.

cadl/__init__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Copyright 2017 Parag K. Mital
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
"""
16+
__version__ = '0.0.1'

cadl/batch_norm.py

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""Batch Normalization for TensorFlow.
2+
"""
3+
"""
4+
Copyright 2017 Parag K. Mital. See also NOTICE.md.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
"""
18+
19+
import tensorflow as tf
20+
from tensorflow.python.ops import control_flow_ops
21+
22+
23+
def batch_norm(x, phase_train, name='bn', decay=0.9, reuse=None, affine=True):
24+
"""
25+
Batch normalization on convolutional maps.
26+
from: https://stackoverflow.com/questions/33949786/how-could-i-
27+
use-batch-normalization-in-tensorflow
28+
Only modified to infer shape from input tensor x.
29+
30+
[DEPRECATED] Use tflearn or slim batch normalization instead.
31+
32+
Parameters
33+
----------
34+
x
35+
Tensor, 4D BHWD input maps
36+
phase_train
37+
boolean tf.Variable, true indicates training phase
38+
name
39+
string, variable name
40+
decay : float, optional
41+
Description
42+
reuse : None, optional
43+
Description
44+
affine
45+
whether to affine-transform outputs
46+
47+
Return
48+
------
49+
normed
50+
batch-normalized maps
51+
"""
52+
with tf.variable_scope(name, reuse=reuse):
53+
shape = x.get_shape().as_list()
54+
beta = tf.get_variable(
55+
name='beta',
56+
shape=[shape[-1]],
57+
initializer=tf.constant_initializer(0.0),
58+
trainable=True)
59+
gamma = tf.get_variable(
60+
name='gamma',
61+
shape=[shape[-1]],
62+
initializer=tf.constant_initializer(1.0),
63+
trainable=affine)
64+
if len(shape) == 4:
65+
batch_mean, batch_var = tf.nn.moments(x, [0, 1, 2], name='moments')
66+
else:
67+
batch_mean, batch_var = tf.nn.moments(x, [0], name='moments')
68+
ema = tf.train.ExponentialMovingAverage(decay=decay)
69+
ema_apply_op = ema.apply([batch_mean, batch_var])
70+
ema_mean, ema_var = ema.average(batch_mean), ema.average(batch_var)
71+
72+
def mean_var_with_update():
73+
with tf.control_dependencies([ema_apply_op]):
74+
return tf.identity(batch_mean), tf.identity(batch_var)
75+
76+
mean, var = control_flow_ops.cond(phase_train, mean_var_with_update,
77+
lambda: (ema_mean, ema_var))
78+
79+
# tf.nn.batch_normalization
80+
normed = tf.nn.batch_norm_with_global_normalization(
81+
x, mean, var, beta, gamma, 1e-6, affine)
82+
return normed

0 commit comments

Comments
 (0)