System.ArgumentOutOfRangeException:'找不到输入列'data'参数名称:inputSchema'

时间:2019-06-02 18:25:24

标签: ml.net

我正在尝试通过导入模型来使用Ml.Net图像分类。我如何在Ml.Net模型中正确引用模型中的正确列。

我尝试使用Neutron来标识系统输入和输出的名称,以将它们作为输入和输出列进行引用。

        var data = mlContext.Data.LoadFromTextFile<ImageData>(path: dataLocation, hasHeader: false);
                    // </SnippetLoadData>

                    // <SnippetMapValueToKey1>
                    var estimator = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: LabelTokey, inputColumnName: "Label")
                                    // </SnippetMapValueToKey1>
                                    // The image transforms transform the images into the model's expected format.
                                    // <SnippetImageTransforms>
                                    .Append(mlContext.Transforms.LoadImages(outputColumnName: "fc8/Softmax", imageFolder: _trainImagesFolder, inputColumnName: nameof(ImageData.ImagePath)))
                                    .Append(mlContext.Transforms.ResizeImages(outputColumnName: "fc8/Softmax", imageWidth: InceptionSettings.ImageWidth, imageHeight: InceptionSettings.ImageHeight,inputColumnName: "data"))
                                    .Append(mlContext.Transforms.ExtractPixels(outputColumnName: "fc8/Softmax", interleavePixelColors: InceptionSettings.ChannelsLast, offsetImage: InceptionSettings.NumberOfChannels))
                                    // </SnippetImageTransforms>
                                    // The ScoreTensorFlowModel transform scores the TensorFlow model and allows communication 
                                    // <SnippetScoreTensorFlowModel>
                                    .Append(mlContext.Model.LoadTensorFlowModel(inputModelLocation).
                                        ScoreTensorFlowModel(outputColumnNames: new[] { "fc8/Softmax" }, inputColumnNames: new[] { "data" }, addBatchDimensionInput: true))
                                    // </SnippetScoreTensorFlowModel>
                                    // <SnippetAddTrainer> 
                                    .Append(mlContext.MulticlassClassification.Trainers.LbfgsMaximumEntropy(labelColumnName: LabelTokey, featureColumnName: "fc8/Softmax"))
                                    // </SnippetAddTrainer>
                                    // <SnippetMapValueToKey2>
                                    .Append(mlContext.Transforms.Conversion.MapKeyToValue(PredictedLabelValue, "PredictedLabel"))
                                    .AppendCacheCheckpoint(mlContext);
                    // </SnippetMapValueToKey2>

                    // Train the model
                    Console.WriteLine("=============== Training classification model ===============");
                    // Create and train the model based on the dataset that has been loaded, transformed.
                    // <SnippetTrainModel>

                    ITransformer model = estimator.Fit(data);
                    // </SnippetTrainModel>

                    // Process the training data through the model
                    // This is an optional step, but it's useful for debugging issues
                    // <SnippetTransformData>
                    var predictions = model.Transform(data);                                            

0 个答案:

没有答案