TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

Evaluate trained model each run different results

Open Tomazzzzz opened this issue 5 years ago • 0 comments

I have code below, each time I run it with the same source data I get different result. Could some one explain what is wrong? `//START var graph = tf.Graph().as_default(); var saver = tf.train.import_meta_graph(_modelMetaPath); var featuresTensor = graph.get_tensor_by_name($"{Features}:0"); var correctPrediction = graph.get_tensor_by_name($"{Prediction}:0"); using (var sess = tf.Session(graph)) { saver.restore(sess, _checkPointPath);

//var featuresTensor = sess.graph.get_tensor_by_name($"{Features}:0");
//var correctPrediction = sess.graph.get_tensor_by_name($"{Prediction}:0");
//Console.WriteLine();

//var graph = tf.Graph().as_default();
//var featuresTensor = graph.get_tensor_by_name($"{Features}:0");
//var correctPrediction = graph.get_tensor_by_name($"{Prediction}:0");

//var featuresTensor = tf.get_collection<Tensor>(Features)[0];
//var correctPrediction = tf.get_collection<Tensor>(Prediction)[0];

var features = new NDArray(NPTypeCode.Float, new Shape(1, featuresTensor.shape[1]));
while (!_stop)
{
	CalculateEvent.WaitOne();
	if (_stop)
		break;
	//var features = new NDArray(NPTypeCode.Float, new Shape(1, featuresTensor.shape[1])) {[0] = _features};
	features[0] = _features;
	var softResult = sess.run(correctPrediction, (featuresTensor, features));
	_result = softResult[0];
	CalculateReadyEvent.Set();
}

}`

Tomazzzzz avatar Jun 25 '21 20:06 Tomazzzzz