daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Mar 19th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2.  
  3.  
  4. def read_input_file(file, matrix):
  5.     i = 0
  6.     for line in file:
  7.         list_line = line.split(',')
  8.         for j, c in enumerate(list_line):
  9.             matrix[i, j] = int(c)
  10.         i += 1
  11.  
  12.     return matrix
  13.  
  14.  
  15. def read_output_file(file, matrix):
  16.     i = 0
  17.     for line in file:
  18.         matrix[i, 0] = int(line[:1])
  19.         i += 1
  20.  
  21.     return matrix
  22.  
  23.  
  24. training_input = read_input_file(open('binMNIST_data/bindigit_trn.csv'), np.zeros(shape=(8000, 784)))
  25. testing_input = read_input_file(open('binMNIST_data/bindigit_tst.csv'), np.zeros(shape=(2000, 784)))
  26. training_out = read_output_file(open('binMNIST_data/targetdigit_trn.csv'), np.zeros(shape=(8000, 1)))
  27. testing_out = read_output_file(open('binMNIST_data/targetdigit_tst.csv'), np.zeros(shape=(2000, 1)))
  28.  
  29. for i in range(28):
  30.     for j in range(28):
  31.         print(str(int(training_input[7999, 28*i+j])), end='')
  32.     print()
RAW Paste Data
Top