如何在 ML.NET 中将数据作为 float32[N,60,1] 插入 ONNX
How insert data in an ONNX as float32[N,60,1] in ML.NET
我正在使用 ML.NET,我想插入一个 float32[N, 60, 1] 作为输入(如图所示)。我不知道如何传递数据。我正在尝试这个 class:
public class OnnxInput
{
[ColumnName("lstm_input")]
public float lstm_input { get; set; }
}
var input = new OnnxInput[length][];
// Here I load the data into the input variable
var dataView = mlContext.Data.LoadFromEnumerable(input);
var pipeline = mlContext.Transforms.
ApplyOnnxModel(
modelFile: modelLocation,
inputColumnNames: new[] { TinyYoloModelSettings.ModelInput },
outputColumnNames: new[] { TinyYoloModelSettings.ModelOutput }
);
var model = pipeline.Fit(data);
创建这个矩阵,当我尝试将数据放入管道时出现错误:System.ArgumentOutOfRangeException: 'Could not determine an IDataView type and registered custom types for member SyncRoot (参数'rawType')'
尝试使用另一种方法,使用此输入 class:
public class OnnxInput
{
[ColumnName("lstm_input")]
public float[] lstm_input { get; set; }
}
var input = new OnnxInput[realLength];
// Here I load the data into the input variable
var dataView = mlContext.Data.LoadFromEnumerable(input);
var pipeline = mlContext.Transforms.
ApplyOnnxModel(
modelFile: modelLocation,
inputColumnNames: new[] { TinyYoloModelSettings.ModelInput },
outputColumnNames: new[] { TinyYoloModelSettings.ModelOutput }
);
var model = pipeline.Fit(data);
创建这个矩阵,当我尝试将数据放入管道时出现错误:System.InvalidOperationException: 'Variable length input columns not supported'
可变输入错误(不支持可变长度输入列)只是意味着您的模型需要固定大小的输入。具体来说,可以在OnnxInput
class.
中的属性lstm_input
之上添加属性[VectorType(60, 1)]
我正在使用 ML.NET,我想插入一个 float32[N, 60, 1] 作为输入(如图所示)。我不知道如何传递数据。我正在尝试这个 class:
public class OnnxInput
{
[ColumnName("lstm_input")]
public float lstm_input { get; set; }
}
var input = new OnnxInput[length][];
// Here I load the data into the input variable
var dataView = mlContext.Data.LoadFromEnumerable(input);
var pipeline = mlContext.Transforms.
ApplyOnnxModel(
modelFile: modelLocation,
inputColumnNames: new[] { TinyYoloModelSettings.ModelInput },
outputColumnNames: new[] { TinyYoloModelSettings.ModelOutput }
);
var model = pipeline.Fit(data);
创建这个矩阵,当我尝试将数据放入管道时出现错误:System.ArgumentOutOfRangeException: 'Could not determine an IDataView type and registered custom types for member SyncRoot (参数'rawType')'
尝试使用另一种方法,使用此输入 class:
public class OnnxInput
{
[ColumnName("lstm_input")]
public float[] lstm_input { get; set; }
}
var input = new OnnxInput[realLength];
// Here I load the data into the input variable
var dataView = mlContext.Data.LoadFromEnumerable(input);
var pipeline = mlContext.Transforms.
ApplyOnnxModel(
modelFile: modelLocation,
inputColumnNames: new[] { TinyYoloModelSettings.ModelInput },
outputColumnNames: new[] { TinyYoloModelSettings.ModelOutput }
);
var model = pipeline.Fit(data);
创建这个矩阵,当我尝试将数据放入管道时出现错误:System.InvalidOperationException: 'Variable length input columns not supported'
可变输入错误(不支持可变长度输入列)只是意味着您的模型需要固定大小的输入。具体来说,可以在OnnxInput
class.
lstm_input
之上添加属性[VectorType(60, 1)]