X_train, Y_train = X, Y Y_vec = Utils.vectorize_output(Y_train, nb_labels) print('Epoch %d' % (i+1)) print("-"*30) nn.initialize_weights() start_time = timer() j_history = nn.train(X_train, Y_vec, alpha, lbda, momentum, precision, nb_iters, verbose=False) total_time = timer() - start_time a.append(len(j_history)) b.append(total_time) c.append(Statistics.accuracy(nn.predict_classes(X_train), Y_train)) d.append(np.mean(np.array(j_history))) # print('Iterations:\t %d' % len(j_history)) # print('Time:\t\t %.9f seconds' % total_time) # print('Accuracy train:\t %.2f' % Statistics.accuracy(nn.predict_classes(X_train), Y_train)) # print('\n') # d.append(np.mean(np.array(j_history))) # colors = "gbrcmyk"*2 # Plots.lineplot(list(range(len(j_history))), j_history, color=colors[k], label='Alpha {}'.format(alpha)) Plots.draw_boundary_rnn(X, nn.predict_classes, nb_hidden=nb_hidden)
# print('Epoch %d' % (i+1)) # print("-"*30) sys.stdout.write("Degree %2d - Alpha %2.2lf - Epoch %2d \r" % (nb_degree, alpha, i+1)) sys.stdout.flush() start_time = timer() lg.initialize_weights() j_history = lg.train(X, Y, alpha, lbda, precision, nb_iters, verbose=False) total_time = timer() - start_time a.append(len(j_history)) b.append(total_time) c.append(Statistics.accuracy(lg.predict_binary(X), Y)) d = j_history # print('Iterations:\t %d' % a[-1]) # print('Time:\t\t %.2f seconds' % b[-1]) # print('Accuracy:\t %.2f' % c[-1]) # f1, precision, recall, acc = Statistics.f_score(lg.predict_binary(X), Y) # print('F1:\t %.2f' % f1) # print('Prec:\t %.2f' % precision) # print('Rec:\t %.2f' % recall) # print('Acc:\t %.2f' % acc) # print('\n') # if nb_degree == 2:
sys.stdout.flush() start_time = timer() lg.initialize_weights() j_history = lg.train(X, Y, alpha, lbda, precision, nb_iters, verbose=False) total_time = timer() - start_time a.append(len(j_history)) b.append(total_time) c.append(Statistics.accuracy(lg.predict_binary(X), Y)) d = j_history # print('Iterations:\t %d' % a[-1]) # print('Time:\t\t %.2f seconds' % b[-1]) # print('Accuracy:\t %.2f' % c[-1]) # f1, precision, recall, acc = Statistics.f_score(lg.predict_binary(X), Y) # print('F1:\t %.2f' % f1) # print('Prec:\t %.2f' % precision) # print('Rec:\t %.2f' % recall) # print('Acc:\t %.2f' % acc) # print('\n') # if nb_degree == 2:
# move enemies and projectiles moveEnemies() moveProjectiles() # check for any collisions if collisionDetection(DISPLAYSURF, BLACK, enemy.getEnemyList(), proj.projectile_list, my_character) == True: # add player to the database insertPlayerRecord(statistics.name, statistics.total_kills, statistics.total_deaths, statistics.blue_kills, statistics.green_kills, statistics.red_kills, statistics.purple_kills, statistics.shots_fired, statistics.shots_hit, statistics.accuracy) # clear the display and show the play again menu DISPLAYSURF.fill((0,0,0)) playAgainMenuOptions = [Option(DISPLAYSURF, BLUE, font, "YES", (config.display_x // 2 - 30, config.display_y // 2)), Option(DISPLAYSURF, BLUE, font, "NO", (config.display_x // 2 - 20, config.display_y // 2 + 100)), Option(DISPLAYSURF, BLUE, font, "MAIN MENU", (config.display_x // 2 - len("MAIN MENU") * 10, config.display_y - 100))] while(playAgainMenu): playAgainMenu = drawPlayAgainMenu(DISPLAYSURF) # update statistics if statistics.shots_fired != 0: statistics.accuracy = statistics.shots_hit / statistics.shots_fired statistics.accuracy = round(statistics.accuracy, 2) # slowly step the difficulty up config.difficulty += config.difficulty_scaler # draw the score onto the surface scoreText = font.render("Score: " + str(statistics.total_kills), True, WHITE, BLACK) textRect = scoreText.get_rect() DISPLAYSURF.blit(scoreText, textRect) pygame.display.update()
nn.initialize_weights() start_time = timer() j_history = nn.train(X_train, Y_vec, alpha, lbda, momentum, precision, nb_iters, verbose=False) total_time = timer() - start_time a.append(len(j_history)) b.append(total_time) c.append(Statistics.accuracy(nn.predict_classes(X_train), Y_train)) d.append(np.mean(np.array(j_history))) # print('Iterations:\t %d' % len(j_history)) # print('Time:\t\t %.9f seconds' % total_time) # print('Accuracy train:\t %.2f' % Statistics.accuracy(nn.predict_classes(X_train), Y_train)) # print('\n') # d.append(np.mean(np.array(j_history))) # colors = "gbrcmyk"*2 # Plots.lineplot(list(range(len(j_history))), j_history, color=colors[k], label='Alpha {}'.format(alpha)) Plots.draw_boundary_rnn(X, nn.predict_classes, nb_hidden=nb_hidden) ma, da = np.mean(np.array(a)), np.std(np.array(a))