This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class model: | |
def __init__(self,outcomes=10): | |
self.model = Sequential() | |
self.model.add(Conv2D(28, (3, 3), activation='relu', input_shape=(28, 28, 1))) | |
self.model.add(MaxPooling2D((2, 2))) | |
self.model.add(Conv2D(64, (3, 3), activation='relu')) | |
self.model.add(MaxPooling2D((2, 2))) | |
self.model.add(Conv2D(64, (3, 3), activation='relu')) | |
self.model.add(Flatten()) | |
self.model.add(Dense(outcomes, activation='sigmoid')) #sigmoid is good for binary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Normalize datasets | |
""" | |
#perform preprocessing scaling of the data | |
toTrain=train_X.reshape(len(train_X),28*28) | |
toTest=test_X.reshape(len(test_X),28*28) | |
scaler1 = preprocessing.StandardScaler().fit(toTrain) | |
X_standard_train = scaler1.transform(toTrain) | |
scaler2 = preprocessing.StandardScaler().fit(toTest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = train_X.shape[1] | |
n = train_X.shape[2] | |
def mandelbrot(height, width, x_from=0, x_to=0.1, y_from=0, y_to=0.1, max_iterations=100): | |
x = np.linspace(x_from, x_to, width).reshape((1, width)) | |
y = np.linspace(y_from, y_to, height).reshape((height, 1)) | |
c = x + 1j * y | |
return c | |
C=mandelbrot(1,28*28).reshape(28,28) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class model: | |
def __init__(self,outcomes=10,numCells=28*28): | |
self.model = Sequential() | |
self.model.add(Dense(100, input_dim=numCells, activation='relu')) #4000 inputs compressed to 200 | |
#model.add(Dense(100, activation='relu')) #keep abstracting information | |
#model.add(Dense(10, activation='relu')) | |
self.model.add(Dense(outcomes, activation='sigmoid')) #sigmoid is good for binary | |
self.model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) | |
def train(self,x,y,epochs=30,batch=32): |