From 2461d2f461bd95d324303e6cc4ea48917269f472 Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Mon, 8 Apr 2019 22:25:08 -0500 Subject: [PATCH] improve performance 10% --- test/TensorFlowNET.Examples/LogisticRegression.cs | 3 +-- test/TensorFlowNET.Examples/Utility/MnistDataSet.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/TensorFlowNET.Examples/LogisticRegression.cs b/test/TensorFlowNET.Examples/LogisticRegression.cs index 248cce31..65025008 100644 --- a/test/TensorFlowNET.Examples/LogisticRegression.cs +++ b/test/TensorFlowNET.Examples/LogisticRegression.cs @@ -53,7 +53,6 @@ namespace TensorFlowNET.Examples return with(tf.Session(), sess => { - // Run the initializer sess.run(init); @@ -71,7 +70,7 @@ namespace TensorFlowNET.Examples new FeedItem(x, batch_xs), new FeedItem(y, batch_ys)); - var c = (float)result[1]; + float c = result[1]; // Compute average loss avg_cost += c / total_batch; } diff --git a/test/TensorFlowNET.Examples/Utility/MnistDataSet.cs b/test/TensorFlowNET.Examples/Utility/MnistDataSet.cs index 2ae1956a..e0e7c0ee 100644 --- a/test/TensorFlowNET.Examples/Utility/MnistDataSet.cs +++ b/test/TensorFlowNET.Examples/Utility/MnistDataSet.cs @@ -96,7 +96,7 @@ namespace TensorFlowNET.Examples.Utility for(int row = 0; row < num_labels; row++) { var col = labels_dense.Data(row); - labels_one_hot[row, col] = 1; + labels_one_hot.SetData(1, row, col); } return labels_one_hot;