Search code examples
pythonneural-networkgzipmnistfile-conversion

How to covert a file to .gz extension


I am working with MNIST data in ML(for digit recognistion) and I want to convert my 'mnist.pkl' to 'mnist.pkl.gz' because the turtorial I am watching uses that extension.This is the file he uses

also if possible please tell me what are those ..... that he has before the file name('.../data/mnist.pkl.gz', 'rb') if you are familiar with it Thank You


Solution

  • The extension .gz indicates that the file was compressed using gzip which you can do by invoking

    gzip mnist.pkl
    

    on the command line. The command will remove the original file and replace it with a compressed version named mnist.pkl.gz.

    That said, you don't have to compress/decompress the file in your particular case. Just use

    f = open('../data.mnist.pkl', 'rb')
    

    instead of

    f = gzip.open('../data.mnist.pkl.gz', 'rb')