Showing error while running the code

The code that u sent is showing error after running for 5 epochs. error is showing as ‘save_imgs’ is not defined.

Hi @pallawishruti02_6305f966b9ec0a96
I have tried running the code my self and it didn’t showed any error. I suspect that you might not had ran the code cell above the training loop i.e. or just add the following code before training loop and your code will work absolutely fine

def save_imgs(epoch,samples=100):
    
    noise = np.random.normal(0,1,size=(samples,NOISE_DIM))
    generated_imgs = generator.predict(noise)
    generated_imgs = generated_imgs.reshape(samples,28,28)
    
    plt.figure(figsize=(10,10))
    for i in range(samples):
        plt.subplot(10,10,i+1)
        plt.imshow(generated_imgs[i],interpolation='nearest',cmap='gray')
        plt.axis("off")
        
    plt.tight_layout()
    plt.savefig('images/gan_output_epoch_{0}.png'.format(epoch+1))
    plt.show() 

Hope this might help :slightly_smiling_face:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.