Ejemplo n.º 1
0
def eval_cnn_model():
    eval_data, eval_data_labels, filelist = read_img_file('eval')
    # evaluate the model and print results
    eval_input_fn = tf.estimator.inputs.numpy_input_fn(x={"x": eval_data},
                                                       y=eval_data_labels,
                                                       num_epochs=1,
                                                       shuffle=False)
    eval_results = cnn_symbol_classifier.evaluate(input_fn=eval_input_fn)
    print(eval_results)
Ejemplo n.º 2
0
def train_cnn_model(steps):
    train_data, train_data_labels = read_img_file('train')

    # set up logging for predictions
    # log the values in the "softmax" tensor with label "probabilities"
    tensors_to_log = {"probabilities": "softmax_tensor"}
    logging_hook = tf.train.LoggingTensorHook(tensors=tensors_to_log,
                                              every_n_iter=50)

    # train the model
    train_input_fn = tf.estimator.inputs.numpy_input_fn(x={"x": train_data},
                                                        y=train_data_labels,
                                                        batch_size=100,
                                                        num_epochs=None,
                                                        shuffle=True)
    print(train_input_fn)
    cnn_symbol_classifier.train(input_fn=train_input_fn,
                                steps=steps,
                                hooks=[logging_hook])