Skip to content

Conversation

@zchen0211
Copy link
Contributor

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.

GAN implementation, just a demo.
'''
# pd for short, should be more concise.
from paddle.v2 as pd
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

batch_z = np.random.uniform(-1., 1., [batch_size, z_dim])

if batch_id % 2 == 0:
sess.run(d_optim,
Copy link
Contributor

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?

Copy link
Contributor Author

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):
Copy link
Contributor

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.

Copy link
Contributor Author

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.

if not self.y_dim:
z = pd.concat(1, [z, y])

G_h0 = pd.fc(z, self.G_w0, self.G_b0)
Copy link
Contributor

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.

@@ -0,0 +1,193 @@
# Design for GAN

GAN (General Adversarial Net) is an important model for unsupervised learning and widely used in many areas.
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Done.


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.
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


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.
Copy link
Member

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 ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Done.

| max-pooling (done) | ? | Y |
| fc (done) | ? | Y |
| softmax loss (done) | ? | Y |
| reshape op (done) | ? | Y |
Copy link
Contributor

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.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ternsor --> tensor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@reyoung reyoung left a 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.

@reyoung reyoung merged commit c193f82 into PaddlePaddle:develop Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants