Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Update Gluon example folder (#12951)
Browse files Browse the repository at this point in the history
* Reorganized the Gluon folder in example

* trigger CI

* update reference

* fix out of place accumulation
  • Loading branch information
ThomasDelteil authored and indhub committed Nov 6, 2018
1 parent 94676b0 commit c169b14
Show file tree
Hide file tree
Showing 16 changed files with 12 additions and 75 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/unsupervised_learning/gan.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ As a result, we have created two neural nets: a Generator, which is able to crea
Along the way, we have learned how to do the image manipulation and visualization that is associated with the training of deep neural nets. We have also learned how to use MXNet's Module APIs to perform advanced model training functionality to fit the model.

## Acknowledgements
This tutorial is based on [MXNet DCGAN codebase](https://github.com/apache/incubator-mxnet/blob/master/example/gluon/dcgan.py),
This tutorial is based on [MXNet DCGAN codebase](https://github.com/apache/incubator-mxnet/blob/master/example/gluon/dc_gan/dcgan.py),
[The original paper on GANs](https://arxiv.org/abs/1406.2661), as well as [this paper on deep convolutional GANs](https://arxiv.org/abs/1511.06434).

<!-- INSERT SOURCE DOWNLOAD BUTTONS -->
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
63 changes: 0 additions & 63 deletions example/gluon/learning_rate_manipulation.py

This file was deleted.

10 changes: 7 additions & 3 deletions example/gluon/lstm_crf.py → example/gluon/lstm_crf/lstm_crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import mxnet.optimizer as optim
import sys

# This example demonstrates how LSTM-CRF model can be implemented in Gluon to perform
# noun-phrase chunking as a sequence labeling task.
# This example demonstrates how the LSTM-CRF model can be implemented
# in Gluon to perform noun-phrase chunking as a sequence labeling task.

mx.random.seed(1)

Expand Down Expand Up @@ -208,7 +208,9 @@ def forward(self, sentence): # dont confuse this with _forward_alg above.

# Make sure prepare_sequence from earlier in the LSTM section is loaded
for epoch in range(300): # again, normally you would NOT do 300 epochs, it is toy data
for sentence, tags in training_data:

neg_log_likelihood_acc = 0.
for i, (sentence, tags) in enumerate(training_data):
# Step 1. Get our inputs ready for the network, that is,
# turn them into Variables of word indices.
# Remember to use autograd to record the calculation.
Expand All @@ -223,6 +225,8 @@ def forward(self, sentence): # dont confuse this with _forward_alg above.
# calling optimizer.step()
neg_log_likelihood.backward()
optimizer.step(1)
neg_log_likelihood_acc += neg_log_likelihood.mean()
print("Epoch [{}], Negative Log Likelihood {:.4f}".format(epoch, neg_log_likelihood_acc.asscalar()/(i+1)))

# Check predictions after training
precheck_sent = prepare_sequence(training_data[0][0], word2idx)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/gluon/sn_gan/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# This example is inspired by https://github.com/jason71995/Keras-GAN-Library,
# https://github.com/kazizzad/DCGAN-Gluon-MxNet/blob/master/MxnetDCGAN.ipynb
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/DCGAN/dcgan.py
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/dc_gan/dcgan.py

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion example/gluon/sn_gan/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# This example is inspired by https://github.com/jason71995/Keras-GAN-Library,
# https://github.com/kazizzad/DCGAN-Gluon-MxNet/blob/master/MxnetDCGAN.ipynb
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/DCGAN/dcgan.py
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/dc_gan/dcgan.py

import mxnet as mx
from mxnet import nd
Expand Down
2 changes: 1 addition & 1 deletion example/gluon/sn_gan/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# This example is inspired by https://github.com/jason71995/Keras-GAN-Library,
# https://github.com/kazizzad/DCGAN-Gluon-MxNet/blob/master/MxnetDCGAN.ipynb
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/DCGAN/dcgan.py
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/dc_gan/dcgan.py


import os
Expand Down
2 changes: 1 addition & 1 deletion example/gluon/sn_gan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# This example is inspired by https://github.com/jason71995/Keras-GAN-Library,
# https://github.com/kazizzad/DCGAN-Gluon-MxNet/blob/master/MxnetDCGAN.ipynb
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/DCGAN/dcgan.py
# https://github.com/apache/incubator-mxnet/blob/master/example/gluon/dc_gan/dcgan.py

import math

Expand Down
4 changes: 0 additions & 4 deletions example/notebooks/README.md

This file was deleted.

0 comments on commit c169b14

Please sign in to comment.