def main(): Xtrain, Ytrain, Xvalid, Yvalid = getImageData() model = CNN( convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[500, 300], ) model.fit(Xtrain, Ytrain, Xvalid, Yvalid)
def main(): X, Y = getImageData() model = CNN( convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[500, 300], ) model.fit(X, Y)
def main(): """main""" # Obtains 4D data for CNN X, Y = getImageData() model = CNN(convpool_layer_sizes=[(32, 5, 5), (64, 5, 5), (128, 5, 5)], hidden_layer_sizes=[500, 300], pool_sz=[(2, 2), (2, 2), (2, 2)]) model.fit(X, Y, show_fig=False)
def main(): X, Y = getImageData() model = CNN( convpool_layer_sizes=[(32, 3, 3), (64, 3, 3), (128, 3, 3), (256, 3, 3)], hidden_layer_sizes=[500, 300], ) model.fit(X, Y, display_cost=True)
def main(): X, Y = getImageData() X = X.transpose(0, 2, 3, 1).astype(np.float32) model = CNN(convpool_sz=[(20, 5, 5), (20, 5, 5)], hidden_sz=[500, 300]) t0 = datetime.now() costs, acc = model.train(X, Y, epochs=500, batch_sz=100) print('Time to train for 1000 epochs w/ batch sz 500: {}'.format( datetime.now() - t0))
def main(argv): pw = argv[0] inputfile = argv[1] # print "password: "******"Input image: " + inputfile key = getKey(pw) # print "Key: " + key.hex data = getImageData(inputfile) bytes = decrypt(data, key) print bytes
def main(): X, Y = getImageData() X = X.transpose((0, 2, 3, 1)) #0=N, 1-Color, 2-Width, 3-Height #No of feature maps, feature width, feature height # No of convpool layers=2 model = CNN( convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[500, 300], ) model.fit(X, Y, show_fig=True)
def main(): Xtrain, Ytrain, Xvalid, Yvalid = getImageData() # reshape X for tf: N x H x W x C Xtrain = Xtrain.transpose((0, 2, 3, 1)) Xvalid = Xvalid.transpose((0, 2, 3, 1)) model = CNN( convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[500, 300], ) model.fit(Xtrain, Ytrain, Xvalid, Yvalid)
def main(): X, Y = getImageData() # reshape X for tf: N x w x h x c X = X.transpose((0, 2, 3, 1)) print("X.shape:", X.shape) model = CNN( convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[500, 300], ) model.fit(X, Y)
def main(): X, Y = getImageData() # reshape X for tf: N x w x h x c X = X.transpose((0, 2, 3, 1)) print "X.shape:", X.shape model = CNN( convpool_layer_sizes=[(20, 5, 5), (20, 5, 5)], hidden_layer_sizes=[500, 300], ) model.fit(X, Y)
def main(): """main""" # Obtains 4D data for CNN X, Y = getImageData() # convert to tf [N,w,h,c] X = X.transpose((0, 2, 3, 1)) print("X.shape:", X.shape) print("Y.shape:", Y.shape) model = CNN( convpool_layer_sizes=[(32, 5, 5), (64, 5, 5), (128, 5, 5)], strides=[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], pool_sz=[[1, 2, 2, 1], [1, 2, 2, 1], [1, 2, 2, 1]], pool_strides=[[1, 2, 2, 1], [1, 2, 2, 1], [1, 2, 2, 1]], hidden_layer_sizes=[500, 300] ) model.fit(X, Y, show_fig=False)
def main(): X, Y = getImageData() # X, Y = shuffle(X, Y) # Xtest, Ytest = X[-8000:,].astype(np.float32), Y[-8000:].astype(np.int32) # X, Y = X[:-8000,].astype(np.float32), Y[:-8000].astype(np.int32) # transpose the data in the tensorflow's order: X = X.transpose((0, 2, 3, 1)) print('Training set shape:', X.shape) # Xtest = Xtest.transpose((0, 2, 3, 1)) # print('Test set shape:', Xtest.shape) model = CNN( convpool_layer_sizes=[(32, 3, 3), (64, 3, 3), (128, 3, 3), (256, 3, 3)], hidden_layer_sizes=[500, 500], ) model.fit(X, Y, display_cost=True) # joblib.dump(model, 'mymodel.pkl') # model = joblib.load('mymodel.pkl') train_acc = model.score(X, Y) print('\nTraining set acc: %.3f' % train_acc)
import numpy as np import matplotlib.pyplot as plt import cnn_tf as cnn import tensorflow as tf from util import getImageData X, Y = getImageData() X = X.transpose(0, 2, 3, 1).astype(np.float32) learning_rates = [10e-3, 10e-4, 10e-5, 10e-6, 10e-7, 10e-8] # best learning rate is 10e-8 # learing_rate = 10e-8 # convLayer_sz = [[(10, 5, 5), (10, 5, 5)], [(20, 5, 5), (20, 5, 5)], # [(30, 5, 5), (30, 5, 5)], [(40, 5, 5), (40, 5, 5)]] convLayer_sz = [(10, 5, 5), (10, 5, 5)] mlpLayer_sz = [500, 300] costs = [] acc = [] file = open('Validation Data Set Scores.txt', 'w') file.write('Validation results:\n') for j, lr in enumerate(learning_rates): # for i, cp in enumerate(convLayer_sz): model = cnn.CNN(convpool_sz=convLayer_sz, hidden_sz=mlpLayer_sz) c, a = model.train(X, Y, learning_rate=lr,