Пример #1
0
def test(sequences, path):
    for gn, sequence in sequences.items():
        res_path = os.path.join(path, "{}.{}".format(gn, 'txt'))

        eq_res, eq_time = condition_of_character_equability(sequence, SEQUENCE_LENGTH, ALFAS)
        write_test_results(eq_res, eq_time, res_path, 'equability')

        ind_res, ind_time = condition_of_character_independence(sequence, SEQUENCE_LENGTH, ALFAS)
        write_test_results(ind_res, ind_time, res_path, 'independence')
        
        uni_res, uni_time = condition_of_character_uniformity(sequence, SEQUENCE_LENGTH, ALFAS, RS)
        write_test_results(uni_res, uni_time, res_path, 'uniformity')
Пример #2
0
    # optimizer
    optimizer = tf.train.AdamOptimizer(0.01)
    train = optimizer.minimize(loss)

    # training loop
    sess = tf.Session()
    sess.run(tf.global_variables_initializer())
    for i in range(1000):
        sess.run(train, {x: x_train, y: y_train})

    # Create dirs as necessary
    if not os.path.exists(CHKP_DIR_NAME):
        os.makedirs(CHKP_DIR_NAME)

    # Save model's checkpoint files
    tf.train.Saver().save(sess, os.path.join(CHKP_DIR_NAME, GRAPH_NAME + '.chkp'))
    tf.summary.FileWriter(CHKP_DIR_NAME, sess.graph)

    # Freeze graph
    freeze_graph(chkp_dir=CHKP_DIR_NAME, out_dir=PB_DIR_NAME, graph_name=GRAPH_NAME, output_node_names=['outputx'])

    # Output results for tests
    test_inputs = read_test_results(in_dir=IN_DIR_NAME, file_name="tf.in")
    test_results = []
    for test_input in test_inputs:
        test_results.append(sess.run(model, feed_dict={
            x: test_input
        }))
    write_test_results(result_list=test_results, out_dir=OUT_DIR_NAME, file_name="tf.out")