SciSharp / SciSharp-Stack-Examples

Practical examples written in SciSharp's machine learning libraries
http://scisharpstack.org
Apache License 2.0
319 stars 103 forks source link

mnist.Train.GetNextBatch Exception #1

Closed xuwaters closed 1 year ago

xuwaters commented 4 years ago

https://github.com/SciSharp/TensorFlow.NET-Examples/blob/24ed42b65bddc655b575532b7089d28aa5b07642/src/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs#L92

When running LogisticRegression Example, I got an Exception:

System.InvalidOperationException: Can't construct NDCoordinatesIncrementor with an empty shape.
   at NumSharp.Utilities.NDCoordinatesIncrementor..ctor(Shape& shape)
   at NumSharp.NDArray._extract_indices(NDArray[] mindices, Boolean isCollapsed, NDArray out)
   at Tensorflow.Hub.MnistDataSet.GetNextBatch(Int32 batch_size, Boolean fake_data, Boolean shuffle)
   at TensorFlowNET.Examples.LogisticRegression.Run() in TensorFlow.NET-Examples/src/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs:line 92
   at TensorFlowNET.Examples.Program.Main(String[] args) in TensorFlow.NET-Examples/src/TensorFlowNET.Examples/Program.cs:line 75

A fix to this example could be modifying this line to the following:

var start = i * batch_size;
var end = (i + 1) * batch_size;
var (batch_xs, batch_ys) = mnist.GetNextBatch(mnist.Train.Data, mnist.Train.Labels, start, end);