Contradictory error messages while training tf.estimator.DNNClassifier

I have been creating a tf.estimator.DNNClassifier model in order to classify data I have into three categories that I have designated as either “0”, “1”, “2”. These values are in a pandas series that I the pass to the model along with the training data in the below code:

classifier = tf.estimator.DNNClassifier(
        # Define the nodes in the two fidden layers
        hidden_units=[30, 10],
        # The model must choose between 3 classes

        input_fn=lambda: input_fn(train, train_y, training=True),

When I run this code and the values are a string I get the Error Message: ValueError: Labels dtype should be integer. Instead got <dtype: 'string'>.

However when I then change these values to integers I get the next error message: TypeError: Expected binary or unicode string, got 0

Both of these error messages are generated when I attempt to train the model I can’t find any reason why I am getting two error messages which seem to contradict each other. Does anyone know what’s going on?

If anymore context is needed such as the surrounding code let me know.

Hi @Asmodeus_03

Welcome to the TensorFlow Forum!

tf.estimator and its’ APIs are deprecated since TensorFlow 2.12 as mentioned in this TensorFlow blog for Deprecating Estimator and migrated to Keras APIs. Could you please try again building this model with the Keras API by referring the Estimators to Keras migration guide and let us know if the issue still persists. Thank you.