diegoalejogm / gans

Generative Adversarial Networks implemented in PyTorch and Tensorflow
MIT License
835 stars 351 forks source link

name "Logger is not defined" #22

Closed muzzi123 closed 3 years ago

muzzi123 commented 4 years ago

1 3

Hello Everyone!

I have two problems when I run this whole script by giving my path of MNIST data

by data folder path is this "C:\Users\muzam\Anaconda3\envs\tensorflow\Data_Practice\train-images-idx3-ubyte\dataset\MNIST"

when I run the "Training code" in juypter

Create logger instance

logger = Logger(model_name='VGAN', data_name='MNIST')

Total number of epochs to train

num_epochs = 20 for epoch in range(num_epochs): for n_batch, (realbatch,) in enumerate(data_loader): N = real_batch.size(0)

1. Train Discriminator

    real_data = Variable(images_to_vectors(real_batch))
    # Generate fake data and detach 
    # (so gradients are not calculated for generator)
    fake_data = generator(noise(N)).detach()
    # Train D
    d_error, d_pred_real, d_pred_fake = \
          train_discriminator(d_optimizer, real_data, fake_data)

    # 2. Train Generator
    # Generate fake data
    fake_data = generator(noise(N))
    # Train G
    g_error = train_generator(g_optimizer, fake_data)
    # Log batch error
    logger.log(d_error, g_error, epoch, n_batch, num_batches)
    # Display Progress every few batches
    if (n_batch) % 100 == 0: 
        test_images = vectors_to_images(generator(test_noise))
        test_images = test_images.data
        logger.log_images(
            test_images, num_test_samples, 
            epoch, n_batch, num_batches
        );
        # Display status Logs
        logger.display_status(
            epoch, num_epochs, n_batch, num_batches,
            d_error, g_error, d_pred_real, d_pred_fake
        )

First it give the error that my kernel is dead

image

then it after kernel is again idle when I run it again it give me the error "name Logger is not defined as shown below

image

And it also generate the folder in data in which subdirectories VGAN and MNIST but this folder are empty.

image

I don't know what the problem can any one tell me the solution.

Thank you very much for you time and consideration. I am waiting for your reply.

Regards:

Muhammad Muzammil Mukhtar

diegoalejogm commented 3 years ago

Hi Muhammad,

The second error occurs because the kernel restarts and you need to import Logger again with import Logger. Could you please share the error message of the colab in this discussion? Does it mention why the Kernel died?

diegoalejogm commented 3 years ago

Closed the issue. Please re-open if you keep having the same problem