from mnist_cnn import DeepCNN import create_data from keras.utils import to_categorical from sklearn.model_selection import train_test_split import numpy as np print("Preparing Data...") num_classes = 10 input_shape = (28, 28, 1) (x_train, y_train), (x_test, y_test) = create_data.load_data() x_train, x_validation, y_train, y_validation = train_test_split(x_train, y_train, test_size=0.2) x_train = x_train.reshape(x_train.shape[0], 28, 28, 1) x_validation = x_validation.reshape(x_validation.shape[0], 28, 28, 1) x_test = x_test.reshape(x_test.shape[0], 28, 28, 1) x_train = x_train.astype('float32') x_validation = x_validation.astype('float32') x_test = x_test.astype('float32') x_train /= 255 x_validation /= 255 x_test /= 255 y_train = to_categorical(y_train, num_classes) y_validation = to_categorical(y_validation, num_classes) y_test = to_categorical(y_test, num_classes)
maxi=maxarea): full_array[k] = 1 k += 1 # conmat[get_score(true, 13390*16), get_score_unet(pred, bias, maxi=maxarea)] +=1 # print(dirs_staexp, '\n', conmat) # tissue = np.count_nonzero(val[:,0]==imnum)*128*128 # print("undecided %: ", np.count_nonzero(predmap==3)/tissue) # a.append(np.count_nonzero(predmap==3)/tissue) return full_array, a if __name__ == '__main__': tic = time.perf_counter() histoImages, masks = load_data() # network patchsize = 128 reso = 4 features = 48 blocks = 5 bias = 13390 # loading [mean, std] = np.load('Processed/ps' + str(patchsize) + 'reso' + str(reso) + 'select/meanstd.npy') train = np.load('Processed/ps' + str(patchsize) + 'reso' + str(reso) + 'select/traindata.npy') val = np.load('Processed/ps' + str(patchsize) + 'reso' + str(reso) + 'select/testdata.npy')
# catsvdogs.py import numpy as np import matplotlib.pyplot as plt import pandas as pd from keras.models import Sequential from keras.layers import Dense, Dropout, Activation, Flatten from keras.layers import MaxPooling2D from keras.layers.convolutional import Conv2D from keras.utils import np_utils from create_data import load_data, load_test_data #load_data() (X_train, y_train, X_test, y_test) = load_data() # Plotting a sample image with label #plt.imshow(X_train[0]) #plt.title(y_train[0]) #plt.show() # Transforming dataset from (n, width, height) to (n, depth, width, height) X_train = X_train.reshape(X_train.shape[0], 50, 50, 1) X_test = X_test.reshape(X_test.shape[0], 50, 50, 1) # The second part of the processing is to convert data type to float32 and normalise data values # to the range of (0 - 1) instead of being (0 - 255) X_train = X_train.astype('float32') X_test = X_test.astype('float32') X_train /= 255 X_test /= 255