![](/img/trans.png)
[英]Two azure function pipeline in CD deploy to one application service not working
[英]pipeline.Fit() Function Not Working in .Net Web Application
当我在我的 Web 应用程序中安装 Microsoft.ML 稳定版本并执行与本教程相同的操作时https://dotnet.microsoft.com/learn/machinelearning-ai/ml-dotnet-get-started-tutorial#install
但是var model = pipeline.Fit(trainingDataView);
此代码不会抛出任何错误或不会继续下一步。 此外,我在控制台应用程序中尝试了相同的步骤并给出了相同的结果。
我的代码是:
var mlContext = new MLContext();
var reader = mlContext.Data.CreateTextReader<IrisData>(separatorChar: ',', hasHeader: true);
IDataView trainingDataView = reader.Read("C:/Users/HACKBAL/Documents/visual studio 2017/Projects/WebApplication1/WebApplication1/Data/Test.txt");
var pipeline = mlContext.Transforms.Conversion.MapValueToKey("Label")
.Append(mlContext.Transforms.Concatenate("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth"))
.Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(labelColumn: "Label", featureColumn: "Features"))
.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
var model = pipeline.Fit(trainingDataView);
var prediction = model.CreatePredictionEngine<IrisData, IrisPrediction>(mlContext).Predict(
new IrisData()
{
SepalLength = 3.3f,
SepalWidth = 1.6f,
PetalLength = 0.2f,
PetalWidth = 5.1f,
});
Console.WriteLine($"Predicted flower type is: {prediction.PredictedLabels}");
我可能有点晚了,但找到了原因和解决方案。 在等待 .Fit() 方法“运行”大约 30 分钟后,它最终给了我以下错误:
显然它正在尝试从远程服务器下载 ResNet 模型。 为什么没有记录在案,为什么要这样做是 Fit() 方法超出我的范围......
无论如何,建议的解决方案是从这里下载元文件:
https://aka.ms/mlnet-resources/meta/resnet_v2_101_299.meta
然后将文件复制到以下文件夹:
C:\\Users\\YourName\\AppData\\Local\\Temp\\MLNET\\
复制文件后,再次运行您的应用程序,它现在应该可以工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.