model = random.choice(models) architecture, step_size, termination, dropout = model models.remove(model) current_params = {'layer_ns': architecture, 'step_size': step_size, 'termination': termination, 'batch_size': batch_size, 'max_example': max_example, 'dropout': dropout} print "##########################################################################" print "Model #%d" % remaining_models print current_params print "##########################################################################" start = time.time() scores = [] cv = 1 cv_start = time.time() for train_index, test_index in KFold(train_inputs[:max_example].shape[0], n_folds=3): X_train, X_test = train_inputs[train_index], train_inputs[test_index] y_train, y_test = train_outputs[train_index], train_outputs[test_index] ffnn = FFNN(X_train[:batch_size], architecture, step_size, termination, dropout=dropout) ffnn.fit(X_train, y_train, X_test, y_test, batch_size=batch_size) score = ffnn.score(X_test, y_test) print "CV " + str(cv) + " score: " + str(score) print "CV " + str(cv) + " time: " + str(time.time() - cv_start) scores += [score] cv += 1 cv_start = time.time() score_avg = sum(scores)/len(scores) current_params['score_avg'] = score_avg current_params['train_time'] = str((time.time() - start)) print "Score average: " + str(score_avg) if score_avg > best_score: print "NEW MAX SCORE: " + str(score_avg) best_score = score_avg best_params = current_params
import numpy as np from ffnn.ffnn import FFNN X = np.asarray([[0,0],[0,1],[1,0],[1,1]]) y = np.asarray([[1,0],[0,1],[0,1],[1,0]]) ffnn = FFNN(X[0],[400,200,100,10,2],.00000000000000001,.01) ffnn.fit(X,y,X,y,batch_size=1)