SciSharp / TensorFlow.NET

.NET Standard bindings for Google's TensorFlow for developing, training and deploying Machine Learning models in C# and F#.
https://scisharp.github.io/tensorflow-net-docs
Apache License 2.0
3.25k stars 524 forks source link

Error in class ImageRecognitionInception #670

Closed ekleiman22 closed 3 years ago

ekleiman22 commented 3 years ago

I downloaded yours TensorFlowNET.Examples and try to check all examples. In example #18 in class ImageRecognitionInception in method ReadTensorFromImageFile I got an error "Object reference not set to an instance of an object." on the line return sess.run(normalized); How to resolve this problem?

Oceania2018 commented 3 years ago

Fixed at https://github.com/SciSharp/SciSharp-Stack-Examples/commit/5c808c7cf9c2c54f530e6e95f2eee4260c6e8a43

ekleiman22 commented 3 years ago

I tried to use your fixed file but it does not pass compilation. For example: in Web.Download Web is unknown (in original version you use Utility.Web.Download). So I did the only correction: I added tf.compat.v1.disable_eager_execution(); in method Run as you did. And now it works.

Oceania2018 commented 3 years ago

Are you sure it's the latest version on your local?

ekleiman22 commented 3 years ago

How can I check it? I did according to https://github.com/SciSharp/SciSharp-Stack-Examples. According this I did: dotnet run --project src/TensorFlowNET.Examples I use Microsoft Visual Studio Community 2019. I executed instructions (yesterday):

install tensorflow C#/F# binding

PM> Install-Package TensorFlow.NET

install keras for tensorflow

PM> Install-Package TensorFlow.Keras

Install tensorflow binary

For CPU version

PM> Install-Package SciSharp.TensorFlow.Redist

I see in packages: TensorFlow.Keras(0.1.0) TensorFlow.NET (0.30.0) SciSharp.TensorFlow.Redist (2.3.1)

Oceania2018 commented 3 years ago

image

ekleiman22 commented 3 years ago

I did all possible updates using NuGet Manager. Now I see in the list of Nuget manager installed packages: TensorFlow.Net v0.31.1 TensorFlow.Keras v0.2.1 SiSharp.TensorFlow.Redist v2.3.1 But now the project TensorFlowNet.Examples does not pass compilation. I get 10 errors such as Error CS1061 'LayersApi' does not contain a definition for 'conv2d' and no accessible extension method 'conv2d' accepting a first argument of type 'LayersApi' could be found (are you missing a using directive or an assembly reference?) TensorFlowNET.Examples C:\Users\eug10\source\repos\SciSharp-Stack-Examples-master\src\TensorFlowNET.Examples\TextProcessing\cnn_models\VdCnn.cs

CS1061 'LayersApi' does not contain a definition for 'conv2d' and no accessible extension method 'conv2d' accepting a first argument of type 'LayersApi' could be found (are you missing a using directive or an assembly reference?) TensorFlowNET.Examples C:\Users\eug10\source\repos\SciSharp-Stack-Examples-master\src\TensorFlowNET.Examples\TextProcessing\cnn_models\WordCnn.cs 52 Active

Error CS1061 'LayersApi' does not contain a definition for 'batch_normalization' and no accessible extension method 'batch_normalization' accepting a first argument of type 'LayersApi' could be found (are you missing a using directive or an assembly reference?) TensorFlowNET.Examples C:\Users\eug10\source\repos\SciSharp-Stack-Examples-master\src\TensorFlowNET.Examples\TextProcessing\cnn_models\VdCnn.cs 151 Active

Oceania2018 commented 3 years ago

Can you try to fork a clean version of the example project?

ekleiman22 commented 3 years ago

Now all examples work. Thank you very much