-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Parag K. Mital
committed
Sep 5, 2017
1 parent
655bef0
commit 577931d
Showing
134 changed files
with
17,663 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2016 Parag K. Mital | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
include HISTORY.md | ||
include README.md | ||
include NOTICE.md | ||
include setup.py | ||
include tox.ini | ||
include conftest.py | ||
|
||
graft docs | ||
|
||
exclude docs/_build | ||
recursive-exclude * __pycache__ | ||
recursive-exclude * *.py[co] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Introduction | ||
|
||
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). | ||
|
||
# Contents | ||
|
||
This package contains various models, architectures, and building blocks covered in the Kadenze Academy program including: | ||
|
||
* Autoencoders | ||
* Character Level Recurrent Neural Network (CharRNN) | ||
* Conditional Pixel CNN | ||
* CycleGAN | ||
* Deep Convolutional Generative Adversarial Networks (DCGAN) | ||
* Deep Dream | ||
* Deep Recurrent Attentive Writer (DRAW) | ||
* Gated Convolution | ||
* Generative Adversarial Networks (GAN) | ||
* Global Vector Embeddings (GloVe) | ||
* Illustration2Vec | ||
* Inception | ||
* Mixture Density Networks (MDN) | ||
* PixelCNN | ||
* NSynth | ||
* Residual Networks | ||
* Sequence2Seqeuence (Seq2Seq) w/ Attention (both bucketed and dynamic rnn variants available) | ||
* Style Net | ||
* Variational Autoencoders (VAE) | ||
* Variational Autoencoding Generative Adversarial Networks (VAEGAN) | ||
* Video Style Net | ||
* VGG16 | ||
* WaveNet / Fast WaveNet Generation w/ Queues / WaveNet Autoencoder (NSynth) | ||
* Word2Vec | ||
|
||
and more. It also includes various datasets, preprocessing, batch generators, input pipelines, and plenty more for datasets such as: | ||
|
||
* CELEB | ||
* CIFAR | ||
* Cornell | ||
* MNIST | ||
* TedLium | ||
* LibriSpeech | ||
* VCTK | ||
|
||
and plenty of utilities for working with images, GIFs, sound (wave) files, MIDI, video, text, TensorFlow, TensorBoard, and their graphs. | ||
|
||
Examples of each module's use can be found in the tests folder. | ||
|
||
# Contributing | ||
|
||
Contributions, such as other model architectures, bug fixes, dataset handling, etc... are welcome and should be filed on the GitHub. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Copyright 2017 Parag K. Mital | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
__version__ = '0.0.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
"""Batch Normalization for TensorFlow. | ||
""" | ||
""" | ||
Copyright 2017 Parag K. Mital. See also NOTICE.md. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
import tensorflow as tf | ||
from tensorflow.python.ops import control_flow_ops | ||
|
||
|
||
def batch_norm(x, phase_train, name='bn', decay=0.9, reuse=None, affine=True): | ||
""" | ||
Batch normalization on convolutional maps. | ||
from: https://stackoverflow.com/questions/33949786/how-could-i- | ||
use-batch-normalization-in-tensorflow | ||
Only modified to infer shape from input tensor x. | ||
[DEPRECATED] Use tflearn or slim batch normalization instead. | ||
Parameters | ||
---------- | ||
x | ||
Tensor, 4D BHWD input maps | ||
phase_train | ||
boolean tf.Variable, true indicates training phase | ||
name | ||
string, variable name | ||
decay : float, optional | ||
Description | ||
reuse : None, optional | ||
Description | ||
affine | ||
whether to affine-transform outputs | ||
Return | ||
------ | ||
normed | ||
batch-normalized maps | ||
""" | ||
with tf.variable_scope(name, reuse=reuse): | ||
shape = x.get_shape().as_list() | ||
beta = tf.get_variable( | ||
name='beta', | ||
shape=[shape[-1]], | ||
initializer=tf.constant_initializer(0.0), | ||
trainable=True) | ||
gamma = tf.get_variable( | ||
name='gamma', | ||
shape=[shape[-1]], | ||
initializer=tf.constant_initializer(1.0), | ||
trainable=affine) | ||
if len(shape) == 4: | ||
batch_mean, batch_var = tf.nn.moments(x, [0, 1, 2], name='moments') | ||
else: | ||
batch_mean, batch_var = tf.nn.moments(x, [0], name='moments') | ||
ema = tf.train.ExponentialMovingAverage(decay=decay) | ||
ema_apply_op = ema.apply([batch_mean, batch_var]) | ||
ema_mean, ema_var = ema.average(batch_mean), ema.average(batch_var) | ||
|
||
def mean_var_with_update(): | ||
with tf.control_dependencies([ema_apply_op]): | ||
return tf.identity(batch_mean), tf.identity(batch_var) | ||
|
||
mean, var = control_flow_ops.cond(phase_train, mean_var_with_update, | ||
lambda: (ema_mean, ema_var)) | ||
|
||
# tf.nn.batch_normalization | ||
normed = tf.nn.batch_norm_with_global_normalization( | ||
x, mean, var, beta, gamma, 1e-6, affine) | ||
return normed |
Oops, something went wrong.