Skip to content

Commit

Permalink
Integrate sayanpa/dcgan3 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Project Philly committed Mar 20, 2017
2 parents 54814cd + 18d0347 commit 637524c
Show file tree
Hide file tree
Showing 6 changed files with 801 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import numpy as np

abs_path = os.path.dirname(os.path.abspath(__file__))
notebook = os.path.join(abs_path, "..", "..", "..", "..", "Tutorials", "CNTK_206_Basic_GAN.ipynb")
notebook = os.path.join(abs_path, "..", "..", "..", "..", "Tutorials", "CNTK_206A_Basic_GAN.ipynb")

def test_cntk_206_basic_gan_noErrors(nb):
def test_cntk_206A_basic_gan_noErrors(nb):
errors = [output for cell in nb.cells if 'outputs' in cell
for output in cell['outputs'] if output.output_type == "error"]
assert errors == []

expectedEvalErrorByDeviceId = { -1: 2.0, 0: 2.05 }
expectedEvalErrorAtolByDeviceId = { -1: 0.45, 0: 0.3 }

def test_cntk_206_basic_gan_evalCorrect(nb, device_id):
def test_cntk_206A_basic_gan_evalCorrect(nb, device_id):
testCell = [cell for cell in nb.cells
if cell.cell_type == 'code' and re.search('# Print the generator loss', cell.source)]
assert len(testCell) == 1
Expand Down
29 changes: 29 additions & 0 deletions Tests/EndToEndTests/CNTKv2Python/Tutorials/CNTK_206B_DCGAN_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) Microsoft. All rights reserved.

# Licensed under the MIT license. See LICENSE.md file in the project root
# for full license information.
# ==============================================================================

import os
import re
import numpy as np

abs_path = os.path.dirname(os.path.abspath(__file__))
notebook = os.path.join(abs_path, "..", "..", "..", "..", "Tutorials", "CNTK_206B_DCGAN.ipynb")
notebook_deviceIdsToRun = [0]
notebook_timeoutSeconds = 900

def test_cntk_206B_dcgan_noErrors(nb):
errors = [output for cell in nb.cells if 'outputs' in cell
for output in cell['outputs'] if output.output_type == "error"]
assert errors == []

expectedEvalError = 2.05
expectedEvalErrorAtol = 0.45

def test_cntk_206B_dcgan_evalCorrect(nb):
testCell = [cell for cell in nb.cells
if cell.cell_type == 'code' and re.search('# Print the generator loss', cell.source)]
assert len(testCell) == 1
m = re.match(r"Training loss of the generator is: (?P<actualEvalError>\d+\.\d+)\r?$", testCell[0].outputs[0]['text'])
assert np.isclose(float(m.group('actualEvalError')), expectedEvalError, atol=expectedEvalErrorAtol)
10 changes: 9 additions & 1 deletion Tools/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,19 @@
{
"category": ["Image"],
"name": "Generative Adversarial Networks (GAN)",
"url": "https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_206_Basic_GAN.ipynb",
"url": "https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_206A_Basic_GAN.ipynb",
"description": "This tutorial is a basic implementation of GAN networks. This allows us generate realistic looking MNIST images with no human input (unsupervised learning).",
"language": ["Python"],
"type": ["Tutorial", "Recipe"]
},
{
"category": ["Image"],
"name": "Deep Convolutional Generative Adversarial Networks (DCGAN)",
"url": "https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_206B_DCGAN.ipynb",
"description": "This tutorial is an implementation of deep convolutional GAN (DCGAN) networks. This allows us generate realistic looking MNIST images with no human input (unsupervised learning).",
"language": ["Python"],
"type": ["Tutorial", "Recipe"]
},
{
"category": ["Image"],
"name": "One Conv",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# CNTK 206: Basic GAN with MNIST data\n",
"# CNTK 206 Part A: Basic GAN with MNIST data\n",
"\n",
"**Prerequisites**: We assume that you have successfully downloaded the MNIST data by completing the tutorial titled CNTK_103A_MNIST_DataLoader.ipynb.\n",
"\n",
Expand Down Expand Up @@ -749,7 +749,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand Down
Loading

0 comments on commit 637524c

Please sign in to comment.