def testValidationAccuracy(): net = memoizeNet() trainX, trainY, validX, validY = getData() [accuracy] = net.evaluate(validX, validY) printColor("Validation Accuracy: {:.2f}%".format(accuracy * 100), "38;32m") return accuracy > 0.95
def testLoadData(): trainX, trainY, validX, validY = getData() return (trainX.shape == (7500, 150, 200, 1) and trainY.shape == (7500, 25) and validX.shape == (2500, 150, 200, 1) and validY.shape == (2500, 25))
# -*- coding: utf-8 -*- """ Created on Wed Sep 20 07:26:13 2017 @author: lxf96 """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import numpy as np import load_data Imgs, labels = load_data.getData() train_Img = load_data.preprocess(Imgs) labels = np.zeros((50000)) for i in range(500): labels[i*100:(i+1)*100]=np.array(range(100)) from keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D, Flatten, Reshape, Lambda, concatenate, Activation, BatchNormalization from keras.layers.advanced_activations import LeakyReLU, PReLU from keras.optimizers import SGD, Adadelta, Adagrad,Adam, rmsprop from keras import objectives from keras.callbacks import TensorBoard from keras import backend as K from keras.models import Model from keras.losses import binary_crossentropy from keras.callbacks import EarlyStopping
''' main file for convolutional Autoencoder ''' from load_data import getData import numpy as np import cv2 from ConvAutoencoder_class import ConvAutoencoder import matplotlib.pyplot as plt #load dataset X_train, Y_train, X_test, Y_test = getData() #creating input tensor X_train = np.reshape(X_train, (len(X_train), 28, 28, 1)) Y_train = np.reshape(Y_train, (len(Y_train), 28, 28, 1)) X_test = np.reshape(X_test, (len(X_test), 28, 28, 1)) Y_test = np.reshape(Y_test, (len(Y_test), 28, 28, 1)) print("Train data orignal:{},rotated:{}".format(np.shape(X_train), np.shape(Y_train))) #train models autoencoder = ConvAutoencoder() autoencoder.train(Y_train, X_train, Y_test, X_test, 256, 10) decoder_image = autoencoder.getDecodedImage(Y_test) #visualization plt.figure(figsize=(20, 4)) for i in range(10): #orignal
from load_data import getData from net import build_net import tflearn netPath = "./net/dni_reader.tfl" net = build_net() net.load(netPath, weights_only=True) trainX, trainY, validX, validY = getData() print "Training Accuracy" print net.evaluate(trainX, trainY)[0] print "Validation Accuracy" print net.evaluate(validX, validY)[0]