-
Notifications
You must be signed in to change notification settings - Fork 1.9k
System.InvalidOperationException when loading tensorflow model #3689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @carlosefrias , could you kindly point us to the frozen model, so we can repro this on our end. Also if you could provide the sample data / code that you are using ? |
@carlosefrias . am closing this since there was no response. please re-open (with sample data/code/model) if u r still facing this issue. |
Hi, I'm using the sample here with this code to create the import tensorflow as tf
f_size = 15 # Number of features passed from ML.Net
num_output = 2 # Number of outputs
tf.set_random_seed(1)
X = tf.placeholder('float', [None, f_size], name="X")
Y = tf.placeholder('float', [None, num_output], name="Y")
lr = tf.placeholder(tf.float32, name = "learning_rate")
# Set model weights
W = tf.Variable(tf.random_normal([f_size,num_output], stddev=0.1), name = 'W')
b = tf.Variable(tf.zeros([num_output]), name = 'b')
l1 = 0
l2 = 0
RegScores = tf.add(tf.matmul(X, W), b, name='RegScores')
loss = tf.reduce_mean(tf.square(Y-tf.squeeze(RegScores))) / 2 + l2 * tf.nn.l2_loss(W) + l1 * tf.reduce_sum(tf.abs(W))
loss = tf.identity(loss, name="Loss")
optimizer = tf.train.MomentumOptimizer(lr, momentum=0.9, name='MomentumOptimizer').minimize(loss)
init = tf.global_variables_initializer()
# Launch the graph.
with tf.Session() as sess:
sess.run(init)
tf.saved_model.simple_save(sess, r'NYCTaxi/model', inputs={'X': X, 'Y': Y}, outputs={'RegScores': RegScores} ) And I get the error:
I think the issue is about providing more information when the TF failed, and not about the problem itself. |
I have the same issue. My code works when I'm using a pretrained mobilenet but fails when I try to run it with my own model. For training the custom model I'm using
|
System information
Windows 10
Visual Studio 2017
.NET Core 2.1
Microsoft.ML v1.0.0 NuGet package
Issue
Based on the example on https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started/DeepLearning_ImageClassification_TensorFlow I tryed to load a tensorflow model using for image segmentation into Microsoft.ML
The model it self was created using keras and then converted to tensorflow using an adapted version of the https://github.com/amir-abdi/keras_to_tensorflow
System.InvalidOperationException when calling LoadTensorFlowModel function
Excepted the model to be loaded.
Source code / logs
at Microsoft.ML.Transforms.TensorFlow.TensorFlowUtils.LoadTFSession(IExceptionContext ectx, Byte[] modelBytes, String modelFile) at Microsoft.ML.TensorflowCatalog.LoadTensorFlowModel(ModelOperationsCatalog catalog, String modelLocation) at ImageClassification.Score.ModelScorer.TFModelScorer.LoadModel(String dataLocation, String imagesFolder, String modelLocation) in C:\Users\me1cme\repos\ml.net-learning\samples\csharp\getting-started\DeepLearning_ImageClassification_TensorFlow\ImageClassification\ModelScorer\TFModelScorer.cs:line 67 at ImageClassification.Score.ModelScorer.TFModelScorer.Score() in C:\Users\me1cme\repos\ml.net-learning\samples\csharp\getting-started\DeepLearning_ImageClassification_TensorFlow\ImageClassification\ModelScorer\TFModelScorer.cs:line 50 at ImageClassification.Program.Main() in C:\Users\me1cme\repos\ml.net-learning\samples\csharp\getting-started\DeepLearning_ImageClassification_TensorFlow\ImageClassification\Program.cs:line 27
Message
TensorFlow exception triggered while loading model from '../../../assets/inputs/final.pb'
Please paste or attach the code or logs or traces that would be helpful to diagnose the issue you are reporting.
The text was updated successfully, but these errors were encountered: