def prepro(X_train, X_val, X_test): mean = np.mean(X_train) return X_train - mean, X_val - mean, X_test - mean if __name__ == '__main__': if len(sys.argv) > 1: net_type = sys.argv[1] valid_nets = ('ff', 'cnn') if net_type not in valid_nets: raise Exception('Valid network type are {}'.format(valid_nets)) else: net_type = 'ff' mnist = input_data.read_data_sets('data/MNIST_data/', one_hot=False) X_train, y_train = mnist.train.images, mnist.train.labels X_val, y_val = mnist.validation.images, mnist.validation.labels X_test, y_test = mnist.test.images, mnist.test.labels M, D, C = X_train.shape[0], X_train.shape[1], y_train.max() + 1 X_train, X_val, X_test = prepro(X_train, X_val, X_test) if net_type == 'cnn': img_shape = (1, 28, 28) X_train = X_train.reshape(-1, *img_shape) X_val = X_val.reshape(-1, *img_shape) X_test = X_test.reshape(-1, *img_shape) solvers = dict(sgd=sgd,
n_experiment = 1 reg = 1e-5 print_after = 50 p_dropout = .8 loss = 'cross_ent' nonlin = 'relu' solver = 'sgd' solver3 = 'sgd3' #worker_num =10 filename1 = './1.txt' filename2 = './2.txt' f1 = open(filename1,'w') f2 = open(filename2,'w') mnist = input_data.read_data_sets('MNIST_Data/',one_hot = True) def prepro(X_train, X_val, X_test): mean = np.mean(X_train) return X_train - mean, X_val - mean, X_test - mean if __name__ == '__main__': if len(sys.argv) > 1: net_type = sys.argv[1] valid_nets = ('ff', 'cnn') if net_type not in valid_nets: raise Exception('Valid network type are {}'.format(valid_nets)) else: net_type = 'cnn'
def prepro(X_train, X_val, X_test): mean = np.mean(X_train) return X_train - mean, X_val - mean, X_test - mean if __name__ == '__main__': if len(sys.argv) > 1: net_type = sys.argv[1] valid_nets = ('ff', 'cnn') if net_type not in valid_nets: raise Exception('Valid network type are {}'.format(valid_nets)) else: net_type = 'ff' mnist = input_data.read_data_sets('data/MNIST_data/', one_hot=False) X_train, y_train = mnist.train.images, mnist.train.labels X_val, y_val = mnist.validation.images, mnist.validation.labels X_test, y_test = mnist.test.images, mnist.test.labels M, D, C = X_train.shape[0], X_train.shape[1], y_train.max() + 1 X_train, X_val, X_test = prepro(X_train, X_val, X_test) if net_type == 'cnn': img_shape = (1, 28, 28) X_train = X_train.reshape(-1, *img_shape) X_val = X_val.reshape(-1, *img_shape) X_test = X_test.reshape(-1, *img_shape) solvers = dict(