machinelearning
machinelearning copied to clipboard
Tensorflow.InvalidArgumentError: Node name contains invalid characters
- OS & Version: [Windows 10]
- ML.NET Version: [ML.NET v2.01]
- .NET Version: [.NET 6.0]
I have trained a DNN model using TensorFlot.NET (0.110.2) and saved the model to directory on my PC. I am then attempting to load the saved model using ML.Net. However, an exception "Node name contains invalid characters" is thrown when I attempt to load the saved model using API LoadTensorFlowModel.
Steps to reproduce :
- Build a Console App targeting .Net 6.0
- Using NuGet Package Manager install Microsoft.ML (2.0.1), Microsoft.ML.TensorFlow (2.0.1) and SciSharp.TensorFlow.Redist (2.11.4)
- Download the attached Zip and extract
- Call DNNLoader.LoadTensorFlowModel(<filePath>) passing the location of the extracted directory
- The exception Tensorflow.InvalidArgumentError: 'Node 'dense_2/bias:': Node name contains invalid characters' is thrown
**Expected ** The trained model to be loaded
Code Sample
using Microsoft.ML; using Microsoft.ML.Data; using Microsoft.ML.Transforms;
namespace DNNPrediction { internal static class DNNLoader { internal static void LoadTensorFlowModel(string modelPath) { MLContext mlContext = new MLContext();
TensorFlowModel tensorFlowModel = mlContext.Model.LoadTensorFlowModel(modelPath);
DataViewSchema schema = tensorFlowModel.GetModelSchema();
Console.WriteLine(" =============== TensorFlow Model Schema =============== ");
var featuresType = (VectorDataViewType)schema["Features"].Type;
Console.WriteLine($"Name: Features, Type: {featuresType.ItemType.RawType}, Size: ({featuresType.Dimensions[0]})");
var predictionType = (VectorDataViewType)schema["Prediction/Softmax"].Type;
Console.WriteLine($"Name: Prediction/Softmax, Type: {predictionType.ItemType.RawType}, Size: ({predictionType.Dimensions[0]})");
}
}
}
The trained model files are here
as far i know ML.NET only support SciSharp.TensorFlow.Redist 2.3.1
Unfortunately I'm facing exactly the same problem, and I cannot find any workaround. Any progress/feedback here?