Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
2 years ago | |
---|---|---|
scripts | 2 years ago | |
src | 2 years ago | |
README.md | 2 years ago | |
eval.py | 2 years ago | |
export.py | 2 years ago | |
mindspore_hub_conf.py | 2 years ago | |
train.py | 2 years ago |
The deep convolutional generative adversarial networks (DCGANs) first introduced CNN into the GAN structure, and the strong feature extraction ability of convolution layer was used to improve the generation effect of GAN.
Paper: Radford A, Metz L, Chintala S. Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks[J]. Computer ence, 2015.
Architecture guidelines for stable Deep Convolutional GANs
Train DCGAN Dataset used: Imagenet-1k
└─imagenet_original
└─train
.
└─dcgan
├─README.md # README
├─scripts # shell script
├─run_standalone_train.sh # training in standalone mode(1pcs)
├─run_distribute_train.sh # training in parallel mode(8 pcs)
└─run_eval.sh # evaluation
├─ src
├─dataset.py // dataset create
├─cell.py // network definition
├─dcgan.py // dcgan structure
├─discriminator.py // discriminator structure
├─generator.py // generator structure
├─config.py // config
├─ train.py // train dcgan
├─ eval.py // eval dcgan
# distributed training
Usage: bash run_train.sh [RANK_TABLE_FILE] [DATASET_PATH] [SAVE_PATH]
# standalone training
Usage: bash run_standalone_train.sh [DATASET_PATH] [SAVE_PATH]
"img_width": 32, # width of the input images
"img_height": 32, # height of the input images
'num_classes': 1000,
'epoch_size': 100,
'batch_size': 128,
'latent_size': 100,
'feature_size': 64,
'channel_size': 3,
'image_height': 32,
'image_width': 32,
'learning_rate': 0.0002,
'beta1': 0.5
config.py
, including learning rate, output filename and network hyperparameters. Click here for more information about dataset.run_standalone_train.sh
for non-distributed training of DCGAN model.# standalone training
run_standalone_train.sh [DATASET_PATH] [SAVE_PATH]
run_distribute_train.sh
for distributed training of DCGAN model.run_train.sh [RANK_TABLE_FILE] [DATASET_PATH] [SAVE_PATH]
Training result will be stored in save_path. You can find checkpoint file.
# standalone training result(1p)
Date time: 2021-04-13 13:55:39 epoch: 0 / 20 step: 0 / 10010 Dloss: 2.2297878 Gloss: 1.1530013
Date time: 2021-04-13 13:56:01 epoch: 0 / 20 step: 50 / 10010 Dloss: 0.21959287 Gloss: 20.064941
Date time: 2021-04-13 13:56:22 epoch: 0 / 20 step: 100 / 10010 Dloss: 0.18872623 Gloss: 5.872738
Date time: 2021-04-13 13:56:44 epoch: 0 / 20 step: 150 / 10010 Dloss: 0.53905165 Gloss: 4.477289
Date time: 2021-04-13 13:57:07 epoch: 0 / 20 step: 200 / 10010 Dloss: 0.47870708 Gloss: 2.2019134
Date time: 2021-04-13 13:57:28 epoch: 0 / 20 step: 250 / 10010 Dloss: 0.3929835 Gloss: 1.8170083
run_eval.sh
for evaluation.# infer
sh run_eval.sh [IMG_URL] [CKPT_URL]
Evaluation result will be stored in the img_url path. Under this, you can find generator result in generate.png.
python export.py --ckpt_file [CKPT_PATH] --device_target [DEVICE_TARGET] --file_format[EXPORT_FORMAT]
EXPORT_FORMAT
should be "MINDIR"
Parameters | Ascend |
---|---|
Model Version | V1 |
Resource | Ascend 910; CPU 2.60GHz, 192cores; Memory, 755G |
uploaded Date | 16/04/2021 (month/day/year) |
MindSpore Version | 1.1.1 |
Dataset | ImageNet2012 |
Training Parameters | epoch=20, batch_size = 128 |
Optimizer | SGD |
Loss Function | Softmax Cross Entropy |
Output | predict class |
Loss | 10.9852 |
Speed | 1pc: 420 ms/step; 8pcs: 143 ms/step |
Total time | 1pc: 24.32 hours |
Checkpoint for Fine tuning | 79.05M(.ckpt file) |
Scripts | dcgan script |
We use random seed in train.py and cell.py for weight initialization.
Please check the official homepage.