Tensorflow predictions change as more predictions are made

孤街浪徒 提交于 2020-01-14 22:48:52

问题


I'm using tensorflow 0.8.0 and skflow (or now known as learn). My model is very similar to this example but with a dnn as the last layer (similar tot he minst example). Nothing very fancy going on, the model works pretty well on its own. The text inputs are a max of 200 characters and 3 classes.

The problem I'm seeing is when I try to load the model and make many predictions (Usually around 200 predictions or more), I start to see results vary.

For example, my model is already trained and I load it and go through my data and make predictions.

char_processor = skflow.preprocessing.ByteProcessor(200)
classifier = skflow.TensorFlowEstimator.restore('/path/to/model')

for item in dataset:
    # each item is an array of strings, ex: ['foo', 'bar', 'hello', 'world']
    line_data = np.array(list(char_processor.transform(item)))
    res = classifier.predict_proba(line_data)

If I load my classifier and only give it one item to predict upon then quit, it works perfectly. When I continue to make predictions, I start to see weirdness.

What could I be missing here? Shouldn't my model always return the same results for the same data?

来源:https://stackoverflow.com/questions/37382704/tensorflow-predictions-change-as-more-predictions-are-made

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!