plt.plot(epochs, loss, 'bo', label='Training loss')
    plt.plot(epochs, val_loss, 'b', label='Validation loss')
    plt.title('Training and validation loss {}'.format(
        datasets_helper.get_dataset_name()))
    plt.xlabel('Epochs')
    plt.ylabel('Loss')
    plt.legend()
    plt.savefig(
        results_saver.get_plot_path(datasets_helper.get_dataset_name(),
                                    "loss"))

    plt.clf()
    acc = history.history['acc']
    val_acc = history.history['val_acc']
    plt.plot(epochs, acc, 'bo', label='Training acc')
    plt.plot(epochs, val_acc, 'b', label='Validation acc')
    plt.title('Training and validation accuracy {}'.format(
        datasets_helper.get_dataset_name()))
    plt.xlabel('Epochs')
    plt.ylabel('Loss')
    plt.legend()
    plt.savefig(
        results_saver.get_plot_path(datasets_helper.get_dataset_name(), "acc"))
    plt.clf()

    results_saver.add_log("Finished testing dataset {}".format(
        datasets_helper.get_dataset_name()))

results_saver.write_2D_list("results", results)
results_saver.end_logging()
예제 #2
0
    neural_lda_out = NeuralTopicMatrix(weight_out, reverse_word_map,
                                       num_of_topics, tokenizer)
    #neural_lda_combined = NeuralTopicMatrix(combined_weight, reverse_word_map,num_of_topics,tokenizer)
    test_model(documents, labels, neural_lda_in, log_writer, 'neural_lda_in')
    test_model(documents, labels, neural_lda_out, log_writer, 'neural_lda_out')
    #test_model(documents, labels, neural_lda_combined, log_writer,'neural_lda_combined')

    try:
        measureCoherence(topic_words_in_max, log_writer, model.dictionary,
                         documents, 'neural_in_max',
                         dataset_helper.get_dataset_name())
    except Exception as exception:
        print(exception)
    #measureCoherence(topic_words_in_min,log_writer,model.dictionary,documents,'neural_in_min',dataset_helper.get_dataset_name())
    try:
        measureCoherence(topic_words_out_max, log_writer, model.dictionary,
                         documents, 'neural_out_max',
                         dataset_helper.get_dataset_name())
    except Exception as exception:
        print(exception)
    #measureCoherence(topic_words_out_min,log_writer,model.dictionary,documents,'neural_out_min',dataset_helper.get_dataset_name())
    #measureCoherence(topic_words_combined, log_writer, model.dictionary, documents, 'neural_combined', dataset_helper.get_dataset_name())

    #plot_clustering_chart(neural_lda_out,False,documents,log_writer,'neural_topic_out',dataset_helper.get_dataset_name(),dataset_helper.get_num_of_topics())
    #plot_clustering_chart(neural_lda_in,False,documents,log_writer,'neural_topic_in',dataset_helper.get_dataset_name(),dataset_helper.get_num_of_topics())
    #plot_clustering_chart(neural_lda_combined,False,documents,log_writer,'neural_topic_combined',dataset_helper.get_dataset_name())

    log_writer.end_logging()

    #print(topic_words)