使用DNNClassifier(估算器)在TensorFlow中显示培训和验证准确性

时间:2017-10-17 08:46:13

标签: tensorflow tensorboard

我想在Tensorboard相同图表中显示训练和验证准确性。

但是,目前我的代码只显示验证准确度点。

我的代码在

之下
def build_estimator(model_dir):
    m = tf.estimator.DNNClassifier(
        model_dir=model_dir,
        feature_columns=deep_columns,
        n_classes=10,
        hidden_units=[512, 256]
    )

    return m

def input_fn(data_file, num_epochs, shuffle):
    labels = data_file['RATING'].astype(int)

    return tf.estimator.inputs.pandas_input_fn(
        x=data_file,
        y=labels,
        batch_size=1,
        num_epochs=num_epochs,
        shuffle=shuffle,
        num_threads=5)

def trains_and_eval( train_data, test_data, train_steps ):
    model_dir = "./board/sample"

    m = build_estimator(model_dir)

    m.train( input_fn=input_fn( train_data, num_epochs=1, shuffle=True), steps=train_steps)

    print("Finished running the deep training via the train() method")

    results = m.evaluate( input_fn=input_fn(test_data, num_epochs=1, shuffle=False), steps=None)

    for key in sorted(results):
        print("%s: %s" % (key, results[key]))

我期待图像。(例如丢失) enter image description here

但目前我的状态 enter image description here

0 个答案:

没有答案
相关问题