Creating and Training a Generative Adversarial Networks (GAN) in Keras (7.2)

Поделиться
HTML-код
  • Опубликовано: 1 янв 2025

Комментарии • 79

  • @HeatonResearch
    @HeatonResearch  5 лет назад +12

    I've updated this video for TensorFlow 2.0, you can see the latest one here: ruclips.net/video/Nrsy6vF7rSw/видео.html

    • @SillyGoose2024
      @SillyGoose2024 4 года назад

      Are you real? Or an elaborate GAN result?

  • @kalaiselvan7840
    @kalaiselvan7840 5 лет назад +25

    This is the best possible explanation of GAN in practise. I have been working with GAN and i havent understood a few things. This video helped me to, thanks a TON Hea"TON"!

  • @TshepoMoagi
    @TshepoMoagi 5 лет назад +8

    As always, good amount of theory makes it easier to understand the application, thanks for the quality work Jeff.

  • @nickcarmont
    @nickcarmont 5 лет назад +4

    Fantastic video, best GANs tutorial on RUclips. Great work.

  • @TheRealKitWalker
    @TheRealKitWalker 4 года назад

    Absolutely Amazing. I just visited the site and my mind is blown by the produced results. Bravo!

  • @joliver1981
    @joliver1981 5 лет назад +1

    So cool. Very glad I found your channel. You deserve to have 10x the subscribers. You make some of the best and most informative videos out there. This is real educational content, not just entertainment. Keep up the great work! 👏👏👏

  • @rchuso
    @rchuso 5 лет назад +1

    This is the first video of yours that I'm going to have to watch a second (and perhaps third) time to understand the structure of the network and how it's trained. I'm just slow.

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      The structure of these is a bit more complex than before. I am working on module 10 right now, doing auto captioning, that is really interesting. The neural network accepts both a sequence (partially built caption for an image) and the image itself. The real power of neural networks is that they are just so abstract on what goes in and out of them.

  • @debajyotisg
    @debajyotisg 5 лет назад +2

    oh how I have waited for this video. Thank you so much

  • @debajyotisg
    @debajyotisg 5 лет назад +1

    At 15:48, should we have calculated the generator metric with x_fake instead?

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      We train it completely end-to-end, it is trained on a random seed, which then generates x_fake. Since we are updating the weights of the generator we need those intermediate values flowing from seed to x_fake.

  • @shivanshsuhane8788
    @shivanshsuhane8788 4 года назад +3

    The kaggle dataset was removed, anyone has the data in google drive? I really want to get a hold of it to follow the tutorial.

  • @wenceslasog786
    @wenceslasog786 3 года назад

    Thank you so much for making this!

  • @iv_lucky
    @iv_lucky 5 лет назад +1

    Thank you for the materials. I loved your video!
    I found some issue: when you change GENERATE_RES, you have to keep in mind the fact: UpSampling with default params increases output shape two times: in rows and columns (4*4->8*8).
    That's why we have to check GENERATE_RES using math.log(GENERATE_RES, 2).is_integer() (for avoid to write more code), because in other case we have discrepancy between generator output shape and discriminator output shape.

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      Thanks for the comment, I will have a look at that.

  • @Dustbinexpress
    @Dustbinexpress 4 года назад +2

    Im trying to apply this to a different set of images with a single channel. somehow the network stops training (loss doesnt change) after 2-3 epochs. I tried to reduce the learning rate to 1e-5 for both generator and discriminator but to no avail. any ideas?

  • @ConfiGProductions
    @ConfiGProductions 4 года назад

    What was that sound in the background at 1:15?

    • @HeatonResearch
      @HeatonResearch  4 года назад +1

      I am not sure, I might have left the ceiling fan on.

  • @yund_eng3490
    @yund_eng3490 3 года назад

    Could someone help me to solve this problem please !?
    Error : could not broadcast input array from shape (64,64,3) into shape (64,64) ...
    Thanks in advance

  • @badrskalli5731
    @badrskalli5731 5 лет назад +1

    Hello Jeff,
    I am having issues with loading the data (see 7:24) as I get the following error:
    ValueError: could not broadcast input array from shape (128,128,3) into shape (128,128)
    The error occurs when trying to reshape the training_data list... Could it be that np.reshape() does not work well with lists?
    Any idea how to solve this? Much appreciated!

    • @yund_eng3490
      @yund_eng3490 3 года назад

      Hi , please , I am getting the same problem did you solve it?

  • @kseniyaburaya3239
    @kseniyaburaya3239 4 года назад

    This is an amazing lesson, thank you!

  • @ras4327
    @ras4327 4 года назад

    i have this problem cannot reshape array of size 792576 into shape (96,96,3)

  • @naisanza
    @naisanza 4 года назад

    I'm not quite seeing how the generator and discriminator gets combined
    I don't see something obvious like, `combined_model = combine(generator, discriminator)`

  • @kiran23500
    @kiran23500 4 года назад

    i am getting this warning after compilation and i cant see any progress in training and it is running from long back
    "Use tf.where in 2.0, which has the same broadcast rule as np.where"

  • @patojp3363
    @patojp3363 2 года назад

    Grande!!

  • @andrewlewis4465
    @andrewlewis4465 5 лет назад

    On this line - discriminator_metric_real = discriminator.train_on_batch(x_real,y_real), I’m getting the error “File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/backend.py", line 3401, in __init__
    raise ValueError('Cannot create an execution function which is comprised '
    ValueError: Cannot create an execution function which is comprised of elements from multiple graphs.” Anyone else get this and if so, what was the fix?”

  • @virentovoshe6773
    @virentovoshe6773 5 лет назад

    I got this error when trying to switch to a higher resolution. It works with 2 but not with 3 or 4. *ValueError: Error when checking input: expected input_28 to have shape (96, 96, 3) but got array with shape (128, 128, 3)*

  • @mpvader1
    @mpvader1 5 лет назад +1

    Great video!

  • @sreeharivr1
    @sreeharivr1 3 года назад

    Can we use GAN in speaker recognition? The code looks the same for GAN compared to DNN. What is the difference in code for GAN compared to DNN ??

    • @HeatonResearch
      @HeatonResearch  3 года назад

      DNN = Deep Neural Network, GAN is just 2 DNN's working against each other to learn to create "fake data". GAN could in theory be used for speaker recognition (such as to recognize one voice from another), the discriminator would learn that if you trained it on one voice.

  • @markpx
    @markpx 5 лет назад +1

    Outstanding!

  • @Western_liberalism
    @Western_liberalism 4 года назад

    how to create a path from google colab to google drive, it won't work for me

  • @cyberfication
    @cyberfication 4 года назад +1

    Alert!
    "Kaggle Lag Dataset: Dataset of faces, from more than 1k different subjects" is either removed from Kaggle or it is a dead link.
    Is there an alternative dataset to train with?

  • @Western_liberalism
    @Western_liberalism 4 года назад

    how do i get these images on to google drive?

  • @melvynsmith8283
    @melvynsmith8283 4 года назад

    The 'Kaggle Lag Dataset: Dataset of faces' seems to be unavailable at the moment.

  • @mertyyanik
    @mertyyanik 5 лет назад +1

    Thanks for the video. I get some error when i want to load images:
    1) 'list' object has no attribute 'reshape'
    2) could not broadcast input array from shape (64,64,4) into shape (64,64)

    • @debajyotisg
      @debajyotisg 5 лет назад

      that is because you are trying to reshape a list. Python cannot do that. You can instead turn it into an np array and then try reshape

  • @crackheads825
    @crackheads825 4 года назад

    Hi Jeff, I have tried to change "GENERATE_RES = 3" and I get an error showing weights miss-match. The same mismatch happens for GENERATE_RES = 4. Can YOu please help me with that.
    I have tried the Latest Updated 2.0 version too!!, and it all works fine for any all the values of GENERATE_RES, but I am not satisfied with the output I get after the generation, so I wish to continue using the previous version, but I am able to train the data only on 64Xg4 images due to the error mismatch. Thank you
    this is the error "ValueError: Error when checking input: expected conv2d_19_input to have shape (128, 128, 3) but got array with shape (256, 256, 3)" for GENERATE_RES = 4, am I missing on something?

  • @ladahlberg
    @ladahlberg 5 лет назад

    Fantastic video! I was able to run it and save the .h5 file at the end. I have two questions. 1) How do you read the h5 file? I tried with pandas but wasn't able to do it. 2) How did you create that little video that shows the training at it progresses (3:25). I would love to do the same. Thank you!

    • @HeatonResearch
      @HeatonResearch  5 лет назад +1

      Sure, the video showing the evolution of the GAN was produced by exporting an image at each training step. The code easily does this. Then just use ffmpeg from the command line to stitch all the images together into a MPEG, and that just became one of my video tracks for the video editing software I use (Camtasia).

    • @ladahlberg
      @ladahlberg 5 лет назад

      @@HeatonResearch Thank you very much! I will try it.

  • @iana_go
    @iana_go 5 лет назад

    Hello Jeff! How can I apply it to the video sequence? Schould I generate it frame by frame?

  • @mayphyu6949
    @mayphyu6949 5 лет назад

    This video helps a lot for a beginner like me. I would like to know what type of GAN is most suitable to create a large dataset for car damage, Sir. Is it possible or not, please advise me, Sir.

  • @salarali1470
    @salarali1470 4 года назад

    Since colab provides ram more than 25gb now. So, can I use resolution higher than 4 ? (Want to use 5)

  • @emersonuyghur007
    @emersonuyghur007 3 года назад

    hi jeff i got error in my code :
    g_loss = sum(gen_loss_list) / len(gen_loss_list)
    18 d_loss = sum(disc_loss_list) / len(disc_loss_list)
    19
    ZeroDivisionError: division by zero

  • @nhanphan1147
    @nhanphan1147 5 лет назад

    Hey Jeff, thanks a lot for the amazing video. However, I've got this error:
    W TensorFlow/core/common_runtime/base_collective_executor.cc:216] BaseCollectiveExecutor::StartAbort Failed precondition: Error while reading resource variable _AnonymousVar85 from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/_AnonymousVar85/class TensorFlow: Var does not exist.
    [[{{node mul_3/ReadVariableOp}}]]
    The traceback indicates the line:
    discriminator_metric_real = discriminator.train_on_batch(x_real, y_real)
    I am very appreciate if you can help

  • @pallabidas3064
    @pallabidas3064 5 лет назад

    Great video. Thanks sir

  • @erciyoung89419
    @erciyoung89419 5 лет назад

    Hi, Jeff. Thank you so much for the video. Would you mind answering some questions? 1) Why we still need to use the ZeroPadding2D layer when 'padding = 'same' has already been set in the build_discriminator? 2) Is there any particular reason for using 'strides = 2'? Thanks

  • @yashoswal7899
    @yashoswal7899 5 лет назад

    Sir can u help me out in my project where in I want to generate smiles but what i don't understand is how to provide noise input to the generator .Smiles is in the format of string which is a canonical form of writing a drug .
    Sir plz explain how to understand what noise should i provide as input to the generator
    Thank you

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      If you are simulating noise, I suggest simulating what distortions your program would likely see in real images being provided to it.

    • @yashoswal7899
      @yashoswal7899 5 лет назад

      Thank you sir I would look into it as you suggested

  • @harperjmusic
    @harperjmusic 5 лет назад

    Great content thanks!

  • @debajyotisg
    @debajyotisg 5 лет назад +1

    at 12:21 you set the discriminator to be non trainable, however at 12:32 you are training the discriminator? I don't follow this

    • @HeatonResearch
      @HeatonResearch  5 лет назад +2

      They are trained separately. The discriminator is trained entirely by itself, using real and fake images. Just under the comment "Train discriminator on real and fake". Only the discriminator's weights are updated. Next we train the generator, but we do this with the generator outputting to the discriminator, like one long neural network. When training the generator we have to set the discriminator's weights to be non-updated so that ONLY the generator is learning and the discriminator is acting as an objective function only. This line "discriminator.trainable = False" does this. If we did not set the discriminator non-trainable, then backpropagation would adjust its weights to benefit the generator and the adversarial nature would be broke. Backprop would damage the discriminator so the generator would do better.

  • @debasisharout8353
    @debasisharout8353 3 года назад

    Thank you sir

  • @debajyotisg
    @debajyotisg 5 лет назад

    When I run this I get an error:
    InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float and shape [?,9,9,1]
    [[node input_1 (defined at :22) ]] [Op:__inference_keras_scratch_graph_4757]
    I am using training_data (of shape (500,9,9,1)). Please help

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      I also emailed you on this (changing my reply now that I had a chance to look at it a bit more). That is a common GAN problem in Keras, one that I have not yet successfully devised a work around for my non-image GAN example. More on the issue here: github.com/keras-team/keras/issues/10074 . I will add a link to this in the course example. I think it has something to do with the BatchNormalize but I've not had time yet to really dig into this one.

    • @debajyotisg
      @debajyotisg 5 лет назад

      @@HeatonResearch I checked the input that goes into the discriminator and it's of shape 9,9,1

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      @@debajyotisg I changed my reply, also see my email.

    • @debajyotisg
      @debajyotisg 5 лет назад

      @@HeatonResearch Thank you sir. I'll go through the GitHub thread.

  • @RetrowaveUniverse
    @RetrowaveUniverse 5 лет назад

    Can I use a different dataset straight from my PC if I just change the PATH?

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      Yes, you can run it locally.

    • @RetrowaveUniverse
      @RetrowaveUniverse 5 лет назад

      @@HeatonResearch Thank you Prof I've done it successfully.

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      @@RetrowaveUniverse Your welcome! Glad it helped.

  • @kashifullah7487
    @kashifullah7487 4 года назад

    Dear sir can I have your email ? I want to use Gain for generating extra sample from my landslides point's. I am working on landslides sustainability mapping and I read one paper they use GAN for generating extra training samples from their landslides inventory. I will share that paper with you thank you very much

  • @luisr1421
    @luisr1421 5 лет назад

    Great video, just curious though. Have I been pronouncing Numpy (num-pie) wrong this whole time? 0.0

    • @HeatonResearch
      @HeatonResearch  5 лет назад

      I usually do not get too hung up on pronunciations. The Lay-text vs Lay-tech are probably the most militant. But from what I read, it can be either way. NumPy (pronounced /ˈnʌmpaɪ/ (NUM-py) or sometimes /ˈnʌmpi/ (NUM-pee)) is a library for the Python programming ...

    • @luisr1421
      @luisr1421 5 лет назад

      Of course, of course. I’ve just never heard it pronounced that way and though I was wrong lol thank you for the reply 🙏

  • @huangbinapple
    @huangbinapple 3 года назад

    I don't think those faces are getting better in latter phase.

  • @rchuso
    @rchuso 4 года назад

    We used to pronounce numpy that way just as a joke on others. Here's someone who knows how to pronounce numpy: ruclips.net/video/P_q0tkYqvSk/видео.html

  • @debunkified
    @debunkified 2 года назад

    English please.

  • @luisborchardt2542
    @luisborchardt2542 2 года назад

    I got this message on this line
    image = Image.open(path).resize((GENERATE_SQUARE,
    IsADirectoryError: [Errno 21] Is a directory: '/content/drive/My Drive/projects/faces/face_images/images'
    can someone help me