I have viewed the previously asked questions pertaining to my query, but need more help in order to view each and every value from the pickled file (MNIST.pkl.gz) I used gzip to unpickle it, and was able to view a part of the array on the Terminal, but rest of the entries were substituted by dots . In order to solve this problem which occurs while printing complete array,I tried a method to print it, but that didn't solve my problem as it primary solves the same problem, but when one is printing using NumPy. Here is my code:
import scipy.io
import pickle
import gzip
#import numpy
#numpy.set_printoptions(threshold=numpy.nan)
#mat=scipy.io.loadmat('traffic_patches.mat')
#print mat
dataset='mnist.pkl.gz'
#unpickling..
f = gzip.open(dataset, 'rb')
training_data, validation_data, test_data = pickle.load(f)
print 'we will print'
print training_data[0], ' ', training_data[1]
print 'we printed'
print training_data
'''f=open('mattext1.txt','w+')
pickle.dump(mat,f)
f.close()
'''
#training_data[0]>file1.txt
f.close()
Found out how to obtain all the values by printing it to a .txt file. Here is the code to print the matrix values in a file and labels on the terminal .
#Supratika
import scipy.io
import pickle
import gzip
import numpy
numpy.set_printoptions(threshold=numpy.nan)
#mat=scipy.io.loadmat('traffic_patches.mat')
#print mat
'''f=open('mattext1.txt','w+')
pickle.dump(mat,f)
f.close()
'''
dataset='mnist.pkl.gz'
#unpickling..
f = gzip.open(dataset, 'rb')
training_data, validation_data, test_data = pickle.load(f)
print 'we will print'
#print training_data[0], ' ', training_data[1]
g=open("sup_data2.txt","w")
for line in training_data[0]:
#print type(line) ---> <type 'numpy.ndarray'>
x=map(str,line.tolist())# makes space separated string frm a list of numbers
g.write(' '.join(x))
#The above prints serially all the 784 pixel values of all the 60,000 images in mnist.
for val in training_data[1]:
#y=map(str,val.tolist())
#g.write(' '.join(y))
print ' ',training_data[1][val] #class labels
g.close
print 'we printed'
#print training_data
#training_data[0]>file1.txt
f.close()