11e9c7adfbf7d50dd9ef4442cf7806cdb2ee2368,samples/core/get_started/premade_estimator.py,,main,#Any#,56

Before Change



    // Generate predictions from the model
    predict_input = make_dataset({
        "SepalLength": [6.4, 5.8],
        "SepalWidth": [3.2, 3.1],
        "PetalLength": [4.5, 5.0],
        "PetalWidth": [1.5, 1.7],
    }).batch(args.batch_size)

    for p in classifier.predict(input_fn=from_dataset(predict_input)):
        template = ("Prediction is "{}" ({:.1f}%)")

        class_id = p["class_ids"][0]

After Change


    test_x = dict(test_x)

    // Feature columns describe how to use the input.
    my_feature_columns = []
    for key in train_x.keys():
        my_feature_columns.append(tf.feature_column.numeric_column(key=key))

    // Build 2 hidden layer DNN with 10, 10 units respectively.
    classifier = tf.estimator.DNNClassifier(
        feature_columns=my_feature_columns,
        // Two hidden layers of 10 nodes each.
        hidden_units=[10, 10],
        // The model must choose between 3 classes.
        n_classes=3)

    // Train the Model.
    classifier.train(
        input_fn=lambda:train_input_fn(train_x, train_y, args.batch_size),
        steps=args.train_steps)

    // Evaluate the model.
    eval_result = classifier.evaluate(
        input_fn=lambda:eval_input_fn(test_x, test_y, args.batch_size))

    print("\nTest set accuracy: {accuracy:0.3f}\n".format(**eval_result))

    // Generate predictions from the model
    expected = ["Setosa", "Versicolor", "Virginica"]
    predict_x = {
        "SepalLength": [5.1, 5.9, 6.9],
        "SepalWidth": [3.3, 3.0, 3.1],
        "PetalLength": [1.7, 4.2, 5.4],
        "PetalWidth": [0.5, 1.5, 2.1],
    }

    predictions = classifier.predict(
        input_fn=lambda:eval_input_fn(predict_x, batch_size=args.batch_size))

    for pred_dict, expec in zip(predictions, expected):
        template = ("\nPrediction is "{}" ({:.1f}%), expected "{}"")

        class_id = pred_dict["class_ids"][0]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: tensorflow/models
Commit Name: 11e9c7adfbf7d50dd9ef4442cf7806cdb2ee2368
Time: 2017-11-17
Author: markdaoust@google.com
File Name: samples/core/get_started/premade_estimator.py
Class Name:
Method Name: main


Project Name: tensorflow/models
Commit Name: 8da4857396fcedb1abd19a08cd4de40d16c7bc50
Time: 2020-08-17
Author: 30733558+plakal@users.noreply.github.com
File Name: research/audioset/yamnet/yamnet_test.py
Class Name: YAMNetTest
Method Name: clip_test


Project Name: tensorflow/models
Commit Name: 11e9c7adfbf7d50dd9ef4442cf7806cdb2ee2368
Time: 2017-11-17
Author: markdaoust@google.com
File Name: samples/core/get_started/custom_estimator.py
Class Name:
Method Name: main