Description
System information
-
OS version/distro:
windows 10
ml.net v0.10.0 -
.NET Version (eg., dotnet --info):
dotcore v2.1
Issue
- What did you do?
- What happened?
- What did you expect?
Source code / logs
I have a tensorflow model, when I use Visual Studio Tools for AI, it auto generator code like this
`
private static List<long> serving_defaultFeaturesShapeForSingleInput = new List<long> { 1, 6, 8 };
private static List<string> serving_defaultInputNames = new List<string> { "features" };
private static List<string> serving_defaultOutputNames = new List<string> { "predictions" };
etc...
/// <summary>
/// Runs inference on abc model for a single input data.
/// </summary>
/// <param name="features">From signature: input 1 with tensor name features; Shape of the input: { 1, 6, 8 }</param>
public IEnumerable<float> Serving_default(IEnumerable<float> features)
{
List<Tensor> result = manager.RunModel(
modelName,
int.MaxValue,
serving_defaultInputNames,
new List<Tensor> { new Tensor(features.ToList(), serving_defaultFeaturesShapeForSingleInput) },
serving_defaultOutputNames
);
List<float> r0 = new List<float>();
result[0].CopyTo(r0);
return r0;
}
`
and everything goes well, I run this instance and got a return.
when I use the ML.Net v0.10.0 try a test the same tensorflow model :
`
public class TensorData
{
[VectorType(1, 4, 6)]
[ColumnName("lstm_1_input")]
public float[] input { get; set; }
}
etc.....
var pipeline = mlContext.Transforms.ScoreTensorFlowModel(
tensorModel, new[] { "lstm_1_input" }, new[] { "lstm_1_input" });
var data = GetTensorData();
var idv = mlContext.Data.ReadFromEnumerable(data);
var trainedModel = pipeline.Fit(idv);
var predicted = trainedModel.Transform(idv);
`
it throw a exception:
System.InvalidOperationException:“Input shape mismatch: Input 'lstm_1_input' has shape [1, 4, 6], but input data is Vec<R4, 1, 4, 6>.”
1、 how to caputure the inputColumnNames/outputColumnNames from a exists model , when Visual Studio Tools for AI use different input/output names ?
2、how to construct a shape [1, 4, 6], when I change input type as float[,,] ,> it throw a
System.InvalidOperationException:“Variable length input columns not supported”.
so how I can correctly use the tensorflow model ? please give a example, thanks much.