Example #1
0
    # trained_model, history = def_train_model.fully_connected_with_dropout_l2(
    #     x_train, x_val, y_train, y_val, MAX_WORDS, MAX_SEQUENCE_LEN, word_index)

    serialize_model_and_history(trained_model, history)
    log_plot_training_performance(history, PLOT=False)  # Note: Cannot plot on Compute Canada nodes.

    # evaluate_model_on_test_set(trained_model, x_test, y_test)

    evaluate_model_on_test_set(trained_model, x_test_asi, y_test_asi, TEST_SET_LABEL='ASI')
    evaluate_model_on_test_set(trained_model, x_test_pan18ap, y_test_pan18ap, TEST_SET_LABEL='PAN18AP')

    # Destroy the current TF graph and create a new one, to ensure reproducible results.
    # This is also useful to avoid clutter from old models/layers.
    K.clear_session()

    # Log run time
    logger.info("@ %.2f seconds: Run finished", time.process_time())


''' 
The following lines will be executed only if this .py file is run as a script,
and not if it is imported as a module.
• __name__ is one of the import-related module attributes, which holds the name of the module.
• A module's __name__ is set to '__main__' when it is running in
the main scope (the scope in which top-level code executes).  
'''
if __name__ == '__main__':
    logger, RUN_TIMESTAMP = my_utils.configure_root_logger(1)
    my_utils.set_working_directory(1)
    main()
Example #2
0
    # At this point, some users might have no tweets, either because an inconsistency between the list of users (when
    # loading the user demographics) and the existing tweets dataset, or because all of their tweets were retweets
    # or short tweets and were dropped in the previous operations.
    # Let's drop those users
    dataset.drop_users_with_no_tweets()

    dataset.drop_users_with_few_total_words(100)

    dataset.produce_stats('ASI dataset stats')
    dataset.labels_to_xml()
    dataset.all_tweets_to_xml()

    # Log run time
    logger.info("@ %.2f seconds: Run finished. Current date and time: %s",
                time.process_time(), datetime.today())


''' 
The following lines will be executed only if this .py file is run as a script,
and not if it is imported as a module.
• __name__ is one of the import-related module attributes, which holds the name of the module.
• A module's __name__ is set to '__main__' when it is running in
the main scope (the scope in which top-level code executes).  
'''
if __name__ == '__main__':
    proj_dir = 'C:/Users/Saman/GitHub/usermodeling'
    logger, RUN_TIMESTAMP = my_utils.configure_root_logger(proj_dir)
    my_utils.set_working_directory(proj_dir)
    main()