Skip to content

Instantly share code, notes, and snippets.

View shepai's full-sized avatar
😁

Dexter Shepherd shepai

😁
View GitHub Profile
@shepai
shepai / ConvNN
Created January 8, 2022 14:48
ConvNN
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
@shepai
shepai / standardize
Created January 7, 2022 11:47
Standardized data
"""
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)
@shepai
shepai / Mandelbrot
Created December 24, 2021 15:10
Mandelbrot generation
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)
@shepai
shepai / NetoworkMnist
Created December 24, 2021 15:05
Network
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):