I am trying to use MNIST data for my research work.Now the dataset description is:
The
training_datais returned as a tuple with two entries. The first entry contains the actual training images. This is a numpy ndarray with 50,000 entries. Each entry is, in turn, a numpy ndarray with 784 values, representing the 28 * 28 = 784 pixels in a single MNIST image.The second entry in the ``training_data`` tuple is a numpy ndarray containing 50,000 entries. Those entries are just the digit values (0...9) for the corresponding images contained in the first entry of the tuple.
Now i am converting the training data like this:
In particular,
training_datais a list containing 50,000 2-tuples(x, y).xis a 784-dimensional numpy.ndarray containing the input image.yis a 10-dimensional numpy.ndarray representing the unit vector corresponding to the correct digit forx. and the code for that is:
def load_data_nn():
training_data, validation_data, test_data = load_data()
#print training_data[0][1]
#inputs = [np.reshape(x, (784, 1)) for x in training_data[0]]
inputs = [np.reshape(x, (784,1)) for x in training_data[0]]
print inputs[0]
results = [vectorized_result(y) for y in training_data[1]]
training_data = zip(inputs, results)
test_inputs = [np.reshape(x, (784, 1)) for x in test_data[0]]
return (training_data, test_inputs, test_data[1])
Now i want to write the inputs into a text file that means one row will be inputs[0] and another row will be inputs[1] and the data inside inputs[0] will be space separated and no ndarray brackets will present.For Example:
0 0.45 0.47 0,76
0.78 0.34 0.35 0.56
Here one row in the text file is inputs[0].How to convert the ndarray to like above in textfile??