dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
9.05k stars 1.89k forks source link

Missing method exception NumSharp.Shape TensorFlow.TensorShape.op_implicit on fit #5241

Closed DanBrook closed 4 years ago

DanBrook commented 4 years ago

System information

Windows 10 pro/18362.836: .NET 4.7.2:

Issue

Got error “Missing method exception NumSharp.Shape TensorFlow.TensorShape.op_implicit” on fit, while trying to run Microsoft example for ML image classification.

Code:

IEstimator pipeline = mlContext.Transforms.LoadImages(outputColumnName: "input", imageFolder: _imagesFolder, inputColumnName: nameof(ImageData.ImagePath)) // The image transforms transform the images into the model's expected format. .Append(mlContext.Transforms.ResizeImages(outputColumnName: "input", imageWidth: InceptionSettings.ImageWidth, imageHeight: InceptionSettings.ImageHeight, inputColumnName: "input")) .Append(mlContext.Transforms.ExtractPixels(outputColumnName: "input", interleavePixelColors: InceptionSettings.ChannelsLast, offsetImage: InceptionSettings.Mean))

.Append(mlContext.Model.LoadTensorFlowModel(_inceptionTensorFlowModel). ScoreTensorFlowModel(outputColumnNames: new[] { "softmax2_pre_activation" }, inputColumnNames: new[] { "input" }, addBatchDimensionInput: true))

.Append(mlContext.Transforms.Conversion.MapValueToKey(outputColumnName: "LabelKey", inputColumnName: "Label"))

.Append(mlContext.MulticlassClassification.Trainers.LbfgsMaximumEntropy(labelColumnName: "LabelKey", featureColumnName: "softmax2_pre_activation"))

.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabelValue", "PredictedLabel")) .AppendCacheCheckpoint(mlContext);

IDataView trainingData = mlContext.Data.LoadFromTextFile(path: _trainTagsTsv, hasHeader: false);

//code above is working properly data preview shows proper data was loaded

ITransformer model = pipeline.Fit(trainingData); // fit ends with error

Numsharp is v0. 20. 5

wangyems commented 4 years ago

Hi @DanBrook, I have this sample run locally without any exceptions. Have you installed the following nuget packages? Microsoft.ML Microsoft.ML.ImageAnalytics SciSharp.TensorFlow.Redist Microsoft.ML.TensorFlow

mstfbl commented 4 years ago

Hi @DanBrook, Your error seems to be because of missing SciSharp.TensorFlow NuGet packages in your project. Have you downloaded this SciSharp NuGet package for training on CPU? If so, please confirm you have done so, so that we can investigate any further possible scenarios. If not, we will close this issue as it most likely is due to the missing SciSharp NuGet package. Thanks!

DanBrook commented 4 years ago

Hi @mstfbl!

Thank you, for fast response. I have downloaded scisharp and have tried to install it from VS and manually, and different versions. Nothing helped. It looks like scisharp installed properly but I still have this error

wangyems commented 4 years ago

Hi @DanBrook , Seems like this linkage issue of SciSharp(Thanks @mstfbl for narrowing down the problem) is probably caused by VS on your machine, Can you try install another VS with different version?(This may not be a good solution but sometimes works) Meanwhile, have you tried deleting the binaries and rebuilding the solution? Thanks

DanBrook commented 4 years ago

Hi @wangyems, I have tried to rebuild and delete binaries. Today I have updated my VS for the last version and my windows too. Reloaded SciSharp and all its dependencies. Still have the same problem.

mstfbl commented 4 years ago

Hey @DanBrook ,

In this case, please share your project with us by following the directions here. We can better support you if we can debug your project with the exact installed packages. You can also email your .zip to Ye and I if you wish. Emails: wangye@microsoft.com, mubal@microsoft.com.

wangyems commented 4 years ago

Closing this issue now. Please feel free to reopen it if you still have any issues.