# Path: little_foo2.py
# def foo():
# 
#     # Determine proper input shape
# 	if keras.__version__ > '1.0.3':
# 		K.set_image_dim_ordering('th')
# 	input_shape = (1, 224, 224)
# 
# 	#img_input = Input(shape=input_shape)
# 
# 	model = Sequential()
# 
# 	model.add(Convolution2D(32, 7, 7,
# 			        input_shape=input_shape,init=weight_init, name='conv1_1'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(32, 5, 5,init=weight_init, name='conv1_2'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(32, 3, 3,init=weight_init, name='conv1_3'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(MaxPooling2D(pool_size=(2, 2))) # in 212, out 106
# 	model.add(Dropout(dropout))
# 
# 	model.add(Convolution2D(64, 7, 7,init=weight_init, name='conv2_1'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(64, 5, 5,init=weight_init, name='conv2_2'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(64, 3, 3,init=weight_init, name='conv2_3'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(MaxPooling2D(pool_size=(2, 2))) # in is 94, out is 47 
# 	model.add(Dropout(dropout))
# 
# 	model.add(Flatten())
# 	model.add(Dense(220, init=weight_init))
# 	model.add(Activation('relu'))
# 	model.add(Dropout(dropout))
# 
# 	model.add(Dense(2))
# 	model.add(Activation('sigmoid'))
# 
# 	return model


import keras
import keras.backend as K
import cPickle
import numpy as np
import getpass
from keras.optimizers import SGD, adadelta, rmsprop, adam
from keras.preprocessing.image import ImageDataGenerator
from keras.utils import np_utils
from keras.metrics import matthews_correlation, precision, recall
from little_foo2 import foo

    	Y_test = np_utils.to_categorical(y_test, nb_classes)

    	X_test /= 255

    	print(X_test.shape[0], 'test samples')
 
    	model.compile(loss='binary_crossentropy', 
                 optimizer= rmsprop(lr=0.001), #adadelta
		 metrics=['accuracy', 'matthews_correlation', 'precision', 'recall', sens, spec])
          
    	score = model.evaluate(X_test, Y_test, verbose=1)

    	print (model.metrics_names, score)

    	if (len(cvscores[0])==0): #if metric names haven't been saved, do so
		cvscores[0].append(model.metrics_names)
    	else:
		counter = 1
		for k in score: #for each test metric, append it to the cvscores list
			cvscores[counter].append(k)
			counter +=1

    	model.reset_states()


def cv_calc():
#calculate mean and stdev for each metric, and append them to test_metrics file
	test_metrics.append(cvscores[0])


# Path: little_foo2.py
# def foo():
# 
#     # Determine proper input shape
# 	if keras.__version__ > '1.0.3':
# 		K.set_image_dim_ordering('th')
# 	input_shape = (1, 224, 224)
# 
# 	#img_input = Input(shape=input_shape)
# 
# 	model = Sequential()
# 
# 	model.add(Convolution2D(32, 7, 7,
# 			        input_shape=input_shape,init=weight_init, name='conv1_1'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(32, 5, 5,init=weight_init, name='conv1_2'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(32, 3, 3,init=weight_init, name='conv1_3'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(MaxPooling2D(pool_size=(2, 2))) # in 212, out 106
# 	model.add(Dropout(dropout))
# 
# 	model.add(Convolution2D(64, 7, 7,init=weight_init, name='conv2_1'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(64, 5, 5,init=weight_init, name='conv2_2'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(Convolution2D(64, 3, 3,init=weight_init, name='conv2_3'))
# 	model.add(BatchNormalization())
# 	model.add(Activation('relu'))
# 	model.add(MaxPooling2D(pool_size=(2, 2))) # in is 94, out is 47 
# 	model.add(Dropout(dropout))
# 
# 	model.add(Flatten())
# 	model.add(Dense(220, init=weight_init))
# 	model.add(Activation('relu'))
# 	model.add(Dropout(dropout))
# 
# 	model.add(Dense(2))
# 	model.add(Activation('sigmoid'))
# 
# 	return model


# Path: test_lilfoo.py
import keras
import keras.backend as K
import cPickle
import numpy as np
import getpass
from keras.optimizers import SGD, adadelta, rmsprop, adam
from keras.preprocessing.image import ImageDataGenerator
from keras.utils import np_utils
from keras.metrics import matthews_correlation, precision, recall
from little_foo2 import foo


    	Y_test = np_utils.to_categorical(y_test, nb_classes)

    	X_test /= 255

    	print(X_test.shape[0], 'test samples')
 
    	model.compile(loss='binary_crossentropy', 
                 optimizer= rmsprop(lr=0.001), #adadelta
		 metrics=['accuracy', 'matthews_correlation', 'precision', 'recall', sens, spec])
          
    	score = model.evaluate(X_test, Y_test, verbose=1)

    	print (model.metrics_names, score)

    	if (len(cvscores[0])==0): #if metric names haven't been saved, do so
		cvscores[0].append(model.metrics_names)
    	else:
		counter = 1
		for k in score: #for each test metric, append it to the cvscores list
			cvscores[counter].append(k)
			counter +=1

    	model.reset_states()


def cv_calc():
#calculate mean and stdev for each metric, and append them to test_metrics file
	test_metrics.append(cvscores[0])


	other_counter = 0