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

TensorFlow.Net 0.100.1 referring to TensorFlow.Keras 0.10.0 AND TensorFlow.Keras 0.10.1 ?

Open Darlanio opened this issue 2 years ago • 4 comments

Using TensorFlow.Net 0.100.1 and either TensorFlow.Keras 0.10.0 OR TensorFlow.Keras 0.10.1 (there is no version 0.10.0.0), I get this message:

System.TypeLoadException HResult=0x80131522 Message=Method 'get_initializers' in type 'Tensorflow.Keras.KerasInterface' from assembly 'Tensorflow.Keras, Version=0.10.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' does not have an implementation. Source=TensorFlowNet-Updated-GAN StackTrace: at TensorFlowNet_Updated_GAN.MnistGAN.PrepareData() in C:\Users\darla\Downloads\TensorFlowNetUpdatedGAN-main\TensorFlowNetUpdatedGAN-main\TensorFlowNet-Updated-GAN\TensorFlowNet-Updated-GAN\MnistGAN.cs:line 57 at TensorFlowNet_Updated_GAN.MnistGAN.Run() in C:\Users\darla\Downloads\TensorFlowNetUpdatedGAN-main\TensorFlowNetUpdatedGAN-main\TensorFlowNet-Updated-GAN\TensorFlowNet-Updated-GAN\MnistGAN.cs:line 40 at TensorFlowNet_Updated_GAN.Program.Main(String[] args) in C:\Users\darla\Downloads\TensorFlowNetUpdatedGAN-main\TensorFlowNetUpdatedGAN-main\TensorFlowNet-Updated-GAN\TensorFlowNet-Updated-GAN\Program.cs:line 15

GitHub repo showing the error: https://github.com/Darlanio/TensorFlowNetUpdatedGAN

Darlanio avatar Jan 29 '23 15:01 Darlanio

Tried using the SciSharp/SciSharp-Stack-Examples-repository and adding the NuGet-Package TensorFlow.Net 0.100.1, but this also gave the error above.

It did work when I added the SciSharp/TensorFlow.Net-repository, removed the dependency to TensorFlow.Keras 0.10.1 from the example and instead added two project references two TensorFlow.Net and TensorFlow.Keras.

I also saw you had replaced the MnistGAN.cs code with my Dense-version... I do not mind it being in the project, but the original one is more efficient when running on a GPU that has enough memory. You can decide which one to use.

Darlanio avatar Jan 29 '23 16:01 Darlanio

Right, I also noticed the original version has better result. You can only install Tensorflow.Keras v0.10.1. It will include the correct version of Tensorflow accordingly. I tested the GAN example in our examples repo, no any error found.

Oceania2018 avatar Jan 29 '23 16:01 Oceania2018

Tested with my repo only using Tensorflow.Keras 0.10.1 and got the error:

System.TypeInitializationException HResult=0x80131534 Message=The type initializer for 'Tensorflow.KerasApi' threw an exception. Source=Tensorflow.Keras StackTrace: at Tensorflow.KerasApi.get_keras() at TensorFlowNet_Updated_GAN.MnistGAN.PrepareData() in C:\Users\darla\Downloads\TensorFlowNetUpdatedGAN-main (1)\TensorFlowNetUpdatedGAN-main\TensorFlowNet-Updated-GAN\TensorFlowNet-Updated-GAN\MnistGAN.cs:line 49 at TensorFlowNet_Updated_GAN.MnistGAN.Run() in C:\Users\darla\Downloads\TensorFlowNetUpdatedGAN-main (1)\TensorFlowNetUpdatedGAN-main\TensorFlowNet-Updated-GAN\TensorFlowNet-Updated-GAN\MnistGAN.cs:line 40 at TensorFlowNet_Updated_GAN.Program.Main(String[] args) in C:\Users\darla\Downloads\TensorFlowNetUpdatedGAN-main (1)\TensorFlowNetUpdatedGAN-main\TensorFlowNet-Updated-GAN\TensorFlowNet-Updated-GAN\Program.cs:line 15

This exception was originally thrown at this call stack: Tensorflow.KerasApi.KerasApi()

Inner Exception 1: TypeLoadException: Method 'SimpleRNN' in type 'Tensorflow.Keras.Layers.LayersApi' from assembly 'Tensorflow.Keras, Version=0.10.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' does not have an implementation.

I also tested the old version without installing Tensorflow.Net and you are right, Tensorflow.Keras will install what it needs on its own. However, with 0.10.0 it will still find 0 Trainable Variables for the generator.

I will test with the SciSharp repository tonight.

Darlanio avatar Jan 30 '23 06:01 Darlanio

Added a GitHub Repo that shows this error in a simple form: https://github.com/Darlanio/TensorFlowNetGAN20230131

I also tried using the SciSharp-repositories instead of NuGet-Packages - and that works: https://github.com/Darlanio/SciSharp-MNISTGAN-Example

I hope this gives a clue about what is wrong.

Darlanio avatar Jan 31 '23 03:01 Darlanio