- Notifications
You must be signed in to change notification settings - Fork 5.9k
API of GAN #4580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API of GAN #4580
Conversation
doc/design/gan_api.md Outdated
| GAN implementation, just a demo. | ||
| ''' | ||
| # pd for short, should be more concise. | ||
| from paddle.v2 as pd |
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.
use
```python
```
that will give a python syntax highlight.
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.
Done.
doc/design/gan_api.md Outdated
| batch_z = np.random.uniform(-1., 1., [batch_size, z_dim]) | ||
| | ||
| if batch_id % 2 == 0: | ||
| sess.run(d_optim, |
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.
use our interface, pd.eval?
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.
Done.
| | ||
| # Conditional-GAN should be a class. | ||
| ### Class member function: the initializer. | ||
| class DCGAN(object): |
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.
no need to be a class, simply 3 functions should be more simple.
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 may have a discussion later. I refer to several GAN models on github, pretty much all looks like this.
doc/design/gan_api.md Outdated
| if not self.y_dim: | ||
| z = pd.concat(1, [z, y]) | ||
| | ||
| G_h0 = pd.fc(z, self.G_w0, self.G_b0) |
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.
fc layer support a param_name argument and generate a unique name , just use it like
G_h0 = pd.fc(z, size=y_dim, param_name="G_fc0")call generator twice will not generate different parameters.
and each fc needn't declare parameters somewhere, so is batchnorm.
doc/design/gan_api.md Outdated
| @@ -0,0 +1,193 @@ | |||
| # Design for GAN | |||
| | |||
| GAN (General Adversarial Net) is an important model for unsupervised learning and widely used in many areas. | |||
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.
maybe add a link to the official definition
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.
Thanks. Done.
doc/design/gan_api.md Outdated
| | ||
| It contains several important machine learning concepts, including building and running subgraphs, dependency tracing, different optimizers in one executor and so forth. | ||
| | ||
| In our GAN design, we wrap it as a user-friendly easily customized python API to design different models. We take the conditional DC-GAN as an example due to its good performance on image generation. |
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.
also, add a link to DC-GAN
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.
Done.
doc/design/gan_api.md Outdated
| | ||
| GAN (General Adversarial Net) is an important model for unsupervised learning and widely used in many areas. | ||
| | ||
| It contains several important machine learning concepts, including building and running subgraphs, dependency tracing, different optimizers in one executor and so forth. |
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.
I think contain is not good, maybe It will use ...?
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.
Thanks. Done.
doc/design/gan_api.md Outdated
| | max-pooling (done) | ? | Y | | ||
| | fc (done) | ? | Y | | ||
| | softmax loss (done) | ? | Y | | ||
| | reshape op (done) | ? | Y | |
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.
I think it is better to create an issue to place this information.
use a - [ ] zzz to create checkboxes to follow up the process.
doc/design/gan_api.md Outdated
| build the whole GAN model, define training loss for both generator and discrimator. | ||
| | ||
| ## Discussion on Engine Functions required to build GAN | ||
| - Trace the ternsor and variable dependency in the engine executor. (Very critical, otherwise GAN can'be be trained correctly) |
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.
ternsor --> tensor
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.
Done.
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.
LGTM
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.
Merge it soon, so we can start to write operators. If there are some errors, we can change it later.
Based on some popular models in TensorFlow and Torch, we design the logic of GAN API.
It is too complex to realize in an op, so I use python API.