-
Notifications
You must be signed in to change notification settings - Fork 150
Add GAN Example #181
Add GAN Example #181
Changes from 14 commits
b16005c
19ba68d
e6edc38
084510e
c70ad3d
e52b0ec
813342d
c00416f
799a3eb
6097719
b218e51
44a1904
39e997a
9a79072
83bdb72
d1ec2bb
4aac95f
e4d3540
dff62cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||
| # Simple GAN | ||||||||
|
|
||||||||
| ### After Epoch 1 | ||||||||
| <p align="center"> | ||||||||
| <img src="images/epoch-1-output.png" height="270" width="360"> | ||||||||
| </p> | ||||||||
|
|
||||||||
| ### After Epoch 10 | ||||||||
|
||||||||
| ### After Epoch 10 | |
| After Epoch 10: | |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ``` | |
| ```sh |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Not sure what you mean exactly by "modules".
- I feel lines 24-30 are unnecessary since they are just describing an installation step that's required for the entire models repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It came from Autoencoder/README.md.
I just copied it and didn't consider much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, we should unify the documentation in all models. @BradLarson how about having a standard README template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rxwei - We definitely will need to rework the READMEs across the examples. Varying levels of information is provided in each, as well as the language used for describing the models. A template for examples would be much appreciated, as well as a good central listing of them. The original Autoencoder README was a little rough (and I think the Python information was confusing and missing the need for matplotlib, etc.), thus the issues with this one derived from it.
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,213 @@ | ||||||||||||
| // Copyright 2019 The TensorFlow Authors. All Rights Reserved. | ||||||||||||
| // | ||||||||||||
| // 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 Foundation | ||||||||||||
| import TensorFlow | ||||||||||||
| import Python | ||||||||||||
|
|
||||||||||||
| // Import Python modules. | ||||||||||||
| let matplotlib = Python.import("matplotlib") | ||||||||||||
| let np = Python.import("numpy") | ||||||||||||
| let plt = Python.import("matplotlib.pyplot") | ||||||||||||
|
|
||||||||||||
| // Turn off using display on server / Linux. | ||||||||||||
| matplotlib.use("Agg") | ||||||||||||
|
|
||||||||||||
| // Some globals | ||||||||||||
|
||||||||||||
| // Some globals |
This comment isn't providing much useful information as the code is self-explanatorily "some globals".
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the first argument label happens to be the object of the overall verb phrase, append it to the base name and omit the argument label.
| func plot(image: Tensor<Float>, name: String) { | |
| func plotImage(_ image: Tensor<Float>, name: String) { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't using Objective-C style formatting for function call arguments. Could you reformat this like the following?
| try! FileManager.default.createDirectory(atPath: outputFolder, | |
| try! FileManager.default.createDirectory( | |
| atPath: outputFolder, | |
| withIntermediateDirectories: false, | |
| attributes: nil) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line, since this is describing both Generator and Discriminator below.
| // Models | |
| // Models | |
BradLarson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var dense1 = Dense<Float>(inputSize: imageSize, outputSize: 256, activation: { leakyRelu($0) }) | |
| var dense1 = Dense<Float>(inputSize: imageSize, outputSize: 256, | |
| activation: { leakyRelu($0) }) |
For consistency with other dense layers below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Loss functions | |
| // Loss functions | |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit redundant type information since it can be inferred from the return type.
| Tensor<Float>(randomNormal: [size, latentSize]) | |
| Tensor(randomNormal: [size, latentSize]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // MNIST data logic | |
| // MNIST data logic | |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant empty line.
BradLarson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| imageGrid = imageGrid.reshaped(to: [(imageHeight+2)*testImageGridSize, | |
| imageGrid = imageGrid.reshaped(to: [(imageHeight + 2) * testImageGridSize, |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| (imageWidth+2)*testImageGridSize]) | |
| (imageWidth + 2) * testImageGridSize]) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant empty line.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let testImage: Tensor<Float> = generator(testVector) | |
| let testImage = generator(testVector) |
Remove redundant type signature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.