TensorFlow Estimator makes different prediction on each call of predict
up vote
0
down vote
favorite
I trained a classifier for the Iris dataset using TF Estimators, but each prediction call I'm getting different results. I wonder if I'm making something wrong in the training or if it is an issue in the prediction.
I'm loading an already trained model and just making the .predict call. This is my input function for prediction.
def get_predict_fn(features,batch_size):
def predict_input_fn():
dataset = tf.data.Dataset.from_tensor_slices(dict(features))
dataset = dataset.batch(batch_size)
return dataset.make_one_shot_iterator().get_next()
return predict_input_fn
This is the result of one call
[{'logits': array([-3.5082035, -1.074667 , -3.8533034],
dtype=float32), 'probabilities': array([0.07629351, 0.8696793 ,
0.05402722], dtype=float32), 'class_ids': array([1]), 'classes': array([b'Iris-versicolor'], dtype=object)}]
This is another call
[{'logits': array([ 3.0530725, -1.0889677, 2.3922846],
dtype=float32), 'probabilities': array([0.6525989 , 0.01037006,
0.337031 ], dtype=float32), 'class_ids': array([0]), 'classes': array([b'Iris-setosa'], dtype=object)}]
Both are making a call to the same model, sending the same example DataFrame.
sepal_length sepal_width petal_length petal_width
5.7 2.5 5.0 2.0
python tensorflow tensorflow-estimator
add a comment |
up vote
0
down vote
favorite
I trained a classifier for the Iris dataset using TF Estimators, but each prediction call I'm getting different results. I wonder if I'm making something wrong in the training or if it is an issue in the prediction.
I'm loading an already trained model and just making the .predict call. This is my input function for prediction.
def get_predict_fn(features,batch_size):
def predict_input_fn():
dataset = tf.data.Dataset.from_tensor_slices(dict(features))
dataset = dataset.batch(batch_size)
return dataset.make_one_shot_iterator().get_next()
return predict_input_fn
This is the result of one call
[{'logits': array([-3.5082035, -1.074667 , -3.8533034],
dtype=float32), 'probabilities': array([0.07629351, 0.8696793 ,
0.05402722], dtype=float32), 'class_ids': array([1]), 'classes': array([b'Iris-versicolor'], dtype=object)}]
This is another call
[{'logits': array([ 3.0530725, -1.0889677, 2.3922846],
dtype=float32), 'probabilities': array([0.6525989 , 0.01037006,
0.337031 ], dtype=float32), 'class_ids': array([0]), 'classes': array([b'Iris-setosa'], dtype=object)}]
Both are making a call to the same model, sending the same example DataFrame.
sepal_length sepal_width petal_length petal_width
5.7 2.5 5.0 2.0
python tensorflow tensorflow-estimator
If you are loading a model, then the results should be consistent. Why might they change? 1. perhaps you are sending different data, but as you state you are sending the same fixed array, so that should not be the cause. 2. you are altering the model after you load it. Can you add the entire code of loading the model and using predict on the fixed input to make sure this is not the case. Otherwise there is not enough information to help
– SumNeuron
8 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I trained a classifier for the Iris dataset using TF Estimators, but each prediction call I'm getting different results. I wonder if I'm making something wrong in the training or if it is an issue in the prediction.
I'm loading an already trained model and just making the .predict call. This is my input function for prediction.
def get_predict_fn(features,batch_size):
def predict_input_fn():
dataset = tf.data.Dataset.from_tensor_slices(dict(features))
dataset = dataset.batch(batch_size)
return dataset.make_one_shot_iterator().get_next()
return predict_input_fn
This is the result of one call
[{'logits': array([-3.5082035, -1.074667 , -3.8533034],
dtype=float32), 'probabilities': array([0.07629351, 0.8696793 ,
0.05402722], dtype=float32), 'class_ids': array([1]), 'classes': array([b'Iris-versicolor'], dtype=object)}]
This is another call
[{'logits': array([ 3.0530725, -1.0889677, 2.3922846],
dtype=float32), 'probabilities': array([0.6525989 , 0.01037006,
0.337031 ], dtype=float32), 'class_ids': array([0]), 'classes': array([b'Iris-setosa'], dtype=object)}]
Both are making a call to the same model, sending the same example DataFrame.
sepal_length sepal_width petal_length petal_width
5.7 2.5 5.0 2.0
python tensorflow tensorflow-estimator
I trained a classifier for the Iris dataset using TF Estimators, but each prediction call I'm getting different results. I wonder if I'm making something wrong in the training or if it is an issue in the prediction.
I'm loading an already trained model and just making the .predict call. This is my input function for prediction.
def get_predict_fn(features,batch_size):
def predict_input_fn():
dataset = tf.data.Dataset.from_tensor_slices(dict(features))
dataset = dataset.batch(batch_size)
return dataset.make_one_shot_iterator().get_next()
return predict_input_fn
This is the result of one call
[{'logits': array([-3.5082035, -1.074667 , -3.8533034],
dtype=float32), 'probabilities': array([0.07629351, 0.8696793 ,
0.05402722], dtype=float32), 'class_ids': array([1]), 'classes': array([b'Iris-versicolor'], dtype=object)}]
This is another call
[{'logits': array([ 3.0530725, -1.0889677, 2.3922846],
dtype=float32), 'probabilities': array([0.6525989 , 0.01037006,
0.337031 ], dtype=float32), 'class_ids': array([0]), 'classes': array([b'Iris-setosa'], dtype=object)}]
Both are making a call to the same model, sending the same example DataFrame.
sepal_length sepal_width petal_length petal_width
5.7 2.5 5.0 2.0
python tensorflow tensorflow-estimator
python tensorflow tensorflow-estimator
asked Nov 10 at 23:46
osanseviero
13
13
If you are loading a model, then the results should be consistent. Why might they change? 1. perhaps you are sending different data, but as you state you are sending the same fixed array, so that should not be the cause. 2. you are altering the model after you load it. Can you add the entire code of loading the model and using predict on the fixed input to make sure this is not the case. Otherwise there is not enough information to help
– SumNeuron
8 hours ago
add a comment |
If you are loading a model, then the results should be consistent. Why might they change? 1. perhaps you are sending different data, but as you state you are sending the same fixed array, so that should not be the cause. 2. you are altering the model after you load it. Can you add the entire code of loading the model and using predict on the fixed input to make sure this is not the case. Otherwise there is not enough information to help
– SumNeuron
8 hours ago
If you are loading a model, then the results should be consistent. Why might they change? 1. perhaps you are sending different data, but as you state you are sending the same fixed array, so that should not be the cause. 2. you are altering the model after you load it. Can you add the entire code of loading the model and using predict on the fixed input to make sure this is not the case. Otherwise there is not enough information to help
– SumNeuron
8 hours ago
If you are loading a model, then the results should be consistent. Why might they change? 1. perhaps you are sending different data, but as you state you are sending the same fixed array, so that should not be the cause. 2. you are altering the model after you load it. Can you add the entire code of loading the model and using predict on the fixed input to make sure this is not the case. Otherwise there is not enough information to help
– SumNeuron
8 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244539%2ftensorflow-estimator-makes-different-prediction-on-each-call-of-predict%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you are loading a model, then the results should be consistent. Why might they change? 1. perhaps you are sending different data, but as you state you are sending the same fixed array, so that should not be the cause. 2. you are altering the model after you load it. Can you add the entire code of loading the model and using predict on the fixed input to make sure this is not the case. Otherwise there is not enough information to help
– SumNeuron
8 hours ago