Пример #1
0
def plot_time_vs_epochs(train_data, test_data):
    timer = Timer()
    number_epochs = []
    time = []
    total_time = 0
    # Build Neural Network
    neural_network = build_network()

    # 200 runs of 100 epochs each
    for i in range(100):
        number_epochs.append(i)
        timer.start()
        for j in range(1000):
            for data in test_data:
                neural_network.feed(data)
        this_time = timer.stop()
        time.append(this_time)
        total_time += this_time
    mean_time = total_time / len(number_epochs)

    # Plot
    plt.figure()
    plt.title("Time Taken in 1000 Epochs", fontsize=20)
    plt.xlabel('Number of Experiment')
    plt.ylabel('Time (seconds)')
    plt.scatter(number_epochs, time, color='blue')
    plt.axhline(y=mean_time, color='r', linestyle='-')
    plt.show()
Пример #2
0
def plot_genetic_algorithm_time():
    timer = Timer()
    experiments = []
    time = []
    total_time = 0
    # Build Neural Network
    genetic_algorithm = GeneticFixedTopology(100, 1000)

    # 20 runs of 1000 generations each
    for i in range(20):
        experiments.append(i)
        timer.start()
        genetic_algorithm.run()
        this_time = timer.stop()
        time.append(this_time)
        genetic_algorithm = GeneticFixedTopology(100, 1000)
        total_time += this_time
    mean_time = total_time / len(experiments)

    # Plot
    plt.figure()
    plt.title("Time Taken in 1000 Generations", fontsize=20)
    plt.xlabel('experimento')
    plt.ylabel('tiempo (segundos)')
    plt.scatter(experiments, time, color='blue')
    plt.axhline(y=mean_time, color='r', linestyle='-')
    plt.show()