MATLAB Answers

Matlab does not currently support Generative Adversarial Neural Networks

22 views (last 30 days)
I searched a lot to see if Matlab supports GAN but unfortunately it does not. I just found deconvolution layer. does anybody know how I can use that for designing a GAN. I am gonna integrate a GAN block within a DAG network and I am not sure if it is possible. I found also another open source lib 'MatConvNet'. is is possible to use it within DAG? Thank you very much I hope it is not wasting time working on deep learning with Matlab.
web address of matconvnet:
web address of DAG :


Show 6 older comments
Walter Roberson
Walter Roberson on 13 Jul 2018
Generative Adversarial Neural Networks are not available in any Mathworks product. They are not supported by the Neural Network toolbox.
Walter Roberson
Walter Roberson on 18 Jul 2018
ashkan dashtban comments to me:
Exactly and we hopefuly expect it to be available in near future!

Sign in to comment.

Accepted Answer

Yui Chun Leung
Yui Chun Leung on 4 Apr 2020
I implemented different types of GANs with Matlab, including DCGAN, cGAN, CycleGAN and more.
You can find my files in FileExchange or Github (


Atallah Baydoun
Atallah Baydoun on 4 Apr 2020
Thanks Yui,
I will take a look and see if I can adapt pix2pix to read .mat files instead of jpg and png.
Yui Chun Leung
Yui Chun Leung on 4 Apr 2020
Here is the code used for transforming jpg and png to mat.
But if you want a dataloader like in pytorch, you have to rewrite the for loop and put the jpg loader in it.

Sign in to comment.

More Answers (5)

Shounak Mitra
Shounak Mitra on 6 Jun 2019
In the next release, we're going to provide some flexbilities to design advanced networks such as GANs, Siamese Networks etc. Hang on :)


ashkan dashtban
ashkan dashtban on 8 Jun 2019
  • we hope Matlab will provide more flexibility in new release to enable us to build hybrid dynamic networks by combining different components of neural networks. Also, If we could add customized metric funciotions, say precision instead of accuracy.! such capability makes MatLab much more powerfull and handy than python!

Sign in to comment.

KH TOHIDUL ISLAM on 19 Sep 2019
It is avilabel now, please check this out. Train Generative Adversarial Network (GAN)

Atallah Baydoun
Atallah Baydoun on 7 Jun 2019
Thanks Mitra for the info.
But when is the next release going to be ?


Show 2 older comments
Atallah Baydoun
Atallah Baydoun on 7 Jun 2019
I am basically interested in DCGAN and cGAN. Will these types be supported ?
Shounak Mitra
Shounak Mitra on 10 Jun 2019
Let's think of it in terms of what important features you need to create GANs - autodifferentiation, custom training loops, and may be custom layers too (if you're curious!). All those things are planned to be supported. And of course, the deep learning layer support will be there.

Sign in to comment.

Wonho Song
Wonho Song on 28 May 2020
Thanks for these nice codes.
Normally we do have checkpoints and model to save to a file.
  1. I want to know how to save the model.Is it good to save the paramGen and paramDis? and if it is then how to use as a model.
  2. 2 .And also I want to know how to test pix2pix.m to a specific image file.Thanks in advance.

  1 Comment

Atallah Baydoun
Atallah Baydoun on 28 May 2020
Hey Wonho,
I ended up by using pix2pix from this link.
It automatically saves the model. You can se from the link that many troubleshooting issues were resolved.

Sign in to comment.

David Willingham
David Willingham on 27 Aug 2020
Since R2019b, MATLAB has supported the implementation of GAN's.
More information on this can be found here.
David Willingham
Deep Learning Product Manager, MathWorks


Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by