176 references to _mlContext
Microsoft.ML.TensorFlow.Tests (176)
TensorflowTests.cs (176)
139var data = TextLoader.Create(_mlContext, new TextLoader.Options() 148var pipeEstimator = new ImageLoadingEstimator(_mlContext, imageFolder, ("ImageReal", "ImagePath")) 149.Append(new ImageResizingEstimator(_mlContext, "ImageCropped", imageHeight, imageWidth, "ImageReal")) 150.Append(new ImagePixelExtractingEstimator(_mlContext, "Input", "ImageCropped", interleavePixelColors: true)) 151.Append(_mlContext.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel("Output", "Input")) 152.Append(new ColumnConcatenatingEstimator(_mlContext, "Features", "Output")) 153.Append(new ValueToKeyMappingEstimator(_mlContext, "Label")) 154.AppendCacheCheckpoint(_mlContext) 155.Append(_mlContext.MulticlassClassification.Trainers.SdcaMaximumEntropy()); 161var metrics = _mlContext.MulticlassClassification.Evaluate(predictions); 164var predictFunction = _mlContext.Model.CreatePredictionEngine<CifarData, CifarPrediction>(transformer); 188var loader = _mlContext.Data.LoadFromEnumerable( 199using var tfModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 287var loader = _mlContext.Data.LoadFromEnumerable(data); 291using var tfModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 409var loader = _mlContext.Data.LoadFromEnumerable(data); 413using var tfModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 505var data = _mlContext.CreateLoader("Text{col=ImagePath:TX:0 col=Name:TX:1}", new MultiFileSource(dataFile)); 506var images = new ImageLoadingTransformer(_mlContext, imageFolder, ("ImageReal", "ImagePath")).Transform(data); 507var cropped = new ImageResizingTransformer(_mlContext, "ImageCropped", 32, 32, "ImageReal").Transform(images); 509var pixels = _mlContext.Transforms.ExtractPixels("image_tensor", "ImageCropped", outputAsFloatArray: false).Fit(cropped).Transform(cropped); 510using var tfModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 541var reader = _mlContext.Data.CreateTextLoader( 553var images = _mlContext.Transforms.LoadImages("ImageReal", "ImagePath", imageFolder).Fit(data).Transform(data); 554var cropped = _mlContext.Transforms.ResizeImages("ImageCropped", 224, 224, "ImageReal").Fit(images).Transform(images); 555var pixels = _mlContext.Transforms.ExtractPixels(inputName, "ImageCropped", interleavePixelColors: true).Fit(cropped).Transform(cropped); 556using var tfModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 579var schema = TensorFlowUtils.GetModelSchema(_mlContext, modelLocation); 640schema = TensorFlowUtils.GetModelSchema(_mlContext, modelLocation); 654var reader = _mlContext.Data.CreateTextLoader( 668var pipe = _mlContext.Transforms.CopyColumns("reshape_input", "Placeholder") 669.Append(_mlContext.Model.LoadTensorFlowModel("mnist_model/frozen_saved_model.pb").ScoreTensorFlowModel(new[] { "Softmax", "dense/Relu" }, new[] { "Placeholder", "reshape_input" })) 670.Append(_mlContext.Transforms.Concatenate("Features", "Softmax", "dense/Relu")) 671.Append(_mlContext.MulticlassClassification.Trainers.LightGbm("Label", "Features")); 675var metrics = _mlContext.MulticlassClassification.Evaluate(predicted); 682var predictFunction = _mlContext.Model.CreatePredictionEngine<MNISTData, MNISTPrediction>(trainedModel); 698var reader = _mlContext.Data.CreateTextLoader(columns: new[] 709var pipe = _mlContext.Transforms.Categorical.OneHotEncoding("OneHotLabel", "Label") 710.Append(_mlContext.Transforms.Normalize(new NormalizingEstimator.MinMaxColumnOptions("Features", "Placeholder"))) 711.Append(_mlContext.Model.RetrainDnnModel( 723.Append(_mlContext.Transforms.Concatenate("Features", "Prediction")) 724.Append(_mlContext.Transforms.Conversion.MapValueToKey("KeyLabel", "Label", maximumNumberOfKeys: 10)) 725.Append(_mlContext.MulticlassClassification.Trainers.LightGbm("KeyLabel", "Features")); 729var metrics = _mlContext.MulticlassClassification.Evaluate(predicted, labelColumnName: "KeyLabel"); 732var predictionFunction = _mlContext.Model.CreatePredictionEngine<MNISTData, MNISTPrediction>(trainedModel); 787var reader = _mlContext.Data.CreateTextLoader(new[] 804preprocessedTrainData = new RowShufflingTransformer(_mlContext, new RowShufflingTransformer.Options() 811preprocessedTestData = new RowShufflingTransformer(_mlContext, new RowShufflingTransformer.Options() 823var pipe = _mlContext.Transforms.CopyColumns("Features", "Placeholder") 824.Append(_mlContext.Model.RetrainDnnModel( 837.Append(_mlContext.Transforms.Concatenate("Features", "Prediction")) 838.AppendCacheCheckpoint(_mlContext) 841.Append(_mlContext.MulticlassClassification.Trainers.LightGbm(new Trainers.LightGbm.LightGbmMulticlassTrainer.Options() 851var metrics = _mlContext.MulticlassClassification.Evaluate(predicted); 856var predictFunction = _mlContext.Model.CreatePredictionEngine<MNISTData, MNISTPrediction>(trainedModel); 880var reader = _mlContext.Data.CreateTextLoader(columns: new[] 892var pipe = _mlContext.Transforms.CopyColumns("reshape_input", "Placeholder") 893.Append(_mlContext.Model.LoadTensorFlowModel("mnist_model").ScoreTensorFlowModel(new[] { "Softmax", "dense/Relu" }, new[] { "Placeholder", "reshape_input" })) 894.Append(_mlContext.Transforms.Concatenate("Features", new[] { "Softmax", "dense/Relu" })) 895.Append(_mlContext.MulticlassClassification.Trainers.LightGbm("Label", "Features")); 899var metrics = _mlContext.MulticlassClassification.Evaluate(predicted); 908var predictFunction = _mlContext.Model.CreatePredictionEngine<MNISTData, MNISTPrediction>(trainedModel); 1001_mlContext.Log += (sender, e) => logMessages.Add(e.Message); 1002using var tensorFlowModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 1011var data = _mlContext.Data.LoadFromTextFile(dataFile, 1019var pipeEstimator = new ImageLoadingEstimator(_mlContext, imageFolder, 1021.Append(new ImageResizingEstimator(_mlContext, "ImageCropped", 1023.Append(new ImagePixelExtractingEstimator(_mlContext, "Input", 1061using var tensorFlowModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 1070var data = _mlContext.Data.LoadFromTextFile(dataFile, columns: new[] 1076var images = _mlContext.Transforms.LoadImages("ImageReal", imageFolder, "ImagePath").Fit(data).Transform(data); 1077var cropped = _mlContext.Transforms.ResizeImages("ImageCropped", imageWidth, imageHeight, "ImageReal").Fit(images).Transform(images); 1078var pixels = _mlContext.Transforms.ExtractPixels("Input", "ImageCropped", interleavePixelColors: true).Fit(cropped).Transform(cropped); 1105using var tensorFlowModel = _mlContext.Model.LoadTensorFlowModel(modelLocation); 1113var dataObjects = InMemoryImage.LoadFromTsv(_mlContext, dataFile, imageFolder); 1115var dataView = _mlContext.Data.LoadFromEnumerable<InMemoryImage>(dataObjects); 1116var pipeline = _mlContext.Transforms.ResizeImages("ResizedImage", imageWidth, imageHeight, nameof(InMemoryImage.LoadedImage)) 1117.Append(_mlContext.Transforms.ExtractPixels("Input", "ResizedImage", interleavePixelColors: true)) 1119.Append(_mlContext.Transforms.Conversion.MapValueToKey("Label")) 1120.Append(_mlContext.MulticlassClassification.Trainers.NaiveBayes("Label", "Output")); 1122var cross = _mlContext.MulticlassClassification.CrossValidate(dataView, pipeline, 2); 1133var schema = TensorFlowUtils.GetModelSchema(_mlContext, modelLocation); 1149var data = TextLoader.Create(_mlContext, new TextLoader.Options() 1158var pipeEstimator = new ImageLoadingEstimator(_mlContext, imageFolder, ("ImageReal", "ImagePath")) 1159.Append(new ImageResizingEstimator(_mlContext, "ImageCropped", imageHeight, imageWidth, "ImageReal")) 1160.Append(new ImagePixelExtractingEstimator(_mlContext, "Input", "ImageCropped", interleavePixelColors: true)) 1161.Append(_mlContext.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel("Output", "Input")) 1162.Append(new ColumnConcatenatingEstimator(_mlContext, "Features", "Output")) 1163.Append(new ValueToKeyMappingEstimator(_mlContext, "Label")) 1164.AppendCacheCheckpoint(_mlContext) 1165.Append(_mlContext.MulticlassClassification.Trainers.NaiveBayes()); 1172var metrics = _mlContext.MulticlassClassification.Evaluate(transformedData); 1175var predictFunction = _mlContext.Model.CreatePredictionEngine<CifarData, CifarPrediction>(transformer); 1185_mlContext.Model.Save(transformer, data.Schema, mlModelLocation); 1191var testTransformer = _mlContext.Model.Load(mlModelLocation, out loadedInputschema); 1196var testPredictFunction = _mlContext.Model.CreatePredictionEngine<CifarData, CifarPrediction>(testTransformer); 1223var data = _mlContext.Data.LoadFromTextFile(dataFile, 1230var images = new ImageLoadingTransformer(_mlContext, imageFolder, ("ImageReal", "ImagePath")).Transform(data); 1231var cropped = new ImageResizingTransformer(_mlContext, "ImageCropped", imageWidth, imageHeight, "ImageReal").Transform(images); 1232var pixels = new ImagePixelExtractingTransformer(_mlContext, "Input", "ImageCropped").Transform(cropped); 1234using TensorFlowModel model = _mlContext.Model.LoadTensorFlowModel(modelLocation); 1264var dataView = _mlContext.Data.LoadFromEnumerable(data); 1266var lookupMap = _mlContext.Data.LoadFromTextFile(@"sentiment_model/imdb_word_index.csv", 1280var estimator = _mlContext.Transforms.Text.TokenizeIntoWords("TokenizedWords", "Sentiment_Text") 1281.Append(_mlContext.Transforms.Conversion.MapValue(lookupMap, lookupMap.Schema["Words"], lookupMap.Schema["Ids"], 1284var dataPipe = _mlContext.Model.CreatePredictionEngine<TensorFlowSentiment, TensorFlowSentiment>(model); 1289using var pipelineModel = _mlContext.Model.LoadTensorFlowModel(modelLocation).ScoreTensorFlowModel(new[] { "Prediction/Softmax" }, new[] { "Features" }) 1290.Append(_mlContext.Transforms.CopyColumns("Prediction", "Prediction/Softmax")) 1292using var tfEnginePipe = _mlContext.Model.CreatePredictionEngine<TensorFlowSentiment, TensorFlowSentiment>(pipelineModel); 1343using var tensorFlowModel = _mlContext.Model.LoadTensorFlowModel(@"model_string_test"); 1348var dataview = _mlContext.Data.CreateTextLoader<TextInput>().Load(new MultiFileSource(null)); 1351.Append(_mlContext.Transforms.CopyColumns(new[] { new InputOutputColumnPair("AOut", "Original_A"), new InputOutputColumnPair("BOut", "Joined_Splited_Text") })); 1352var transformer = _mlContext.Model.CreatePredictionEngine<TextInput, TextOutput>(pipeline.Fit(dataview)); 1370using var tensorFlowModel = _mlContext.Model.LoadTensorFlowModel(@"model_primitive_input_test"); 1377var dataview = _mlContext.Data.CreateTextLoader<PrimitiveInput>().Load(new MultiFileSource(null)); 1382var transformer = _mlContext.Model.CreatePredictionEngine<PrimitiveInput, PrimitiveOutput>(pipeline.Fit(dataview)); 1403IDataView shuffledFullImagesDataset = _mlContext.Data.ShuffleRows( 1404_mlContext.Data.LoadFromEnumerable(images), seed: 1); 1406shuffledFullImagesDataset = _mlContext.Transforms.Conversion 1412TrainTestData trainTestData = _mlContext.Data.TrainTestSplit( 1418var pipeline = _mlContext.Transforms.LoadRawImageBytes("Image", _fullImagesetFolderPath, "ImagePath") 1419.Append(_mlContext.MulticlassClassification.Trainers.ImageClassification("Label", "Image") 1420.Append(_mlContext.Transforms.Conversion.MapKeyToValue(outputColumnName: "PredictedLabel", inputColumnName: "PredictedLabel"))); ; 1424_mlContext.Model.Save(trainedModel, shuffledFullImagesDataset.Schema, 1430loadedModel = _mlContext.Model.Load(file, out schema); 1434var metrics = _mlContext.MulticlassClassification.Evaluate(predictions); 1478IDataView shuffledFullImagesDataset = _mlContext.Data.ShuffleRows( 1479_mlContext.Data.LoadFromEnumerable(images), seed: 1); 1481shuffledFullImagesDataset = _mlContext.Transforms.Conversion 1487TrainTestData trainTestData = _mlContext.Data.TrainTestSplit( 1492var validationSet = _mlContext.Transforms.LoadRawImageBytes("Image", _fullImagesetFolderPath, "ImagePath") 1521var pipeline = _mlContext.Transforms.LoadRawImageBytes("Image", _fullImagesetFolderPath, "ImagePath") 1522.Append(_mlContext.MulticlassClassification.Trainers.ImageClassification(options) 1523.Append(_mlContext.Transforms.Conversion.MapKeyToValue(outputColumnName: "PredictedLabel", inputColumnName: "PredictedLabel"))); 1527_mlContext.Model.Save(trainedModel, shuffledFullImagesDataset.Schema, 1533loadedModel = _mlContext.Model.Load(file, out schema); 1537var metrics = _mlContext.MulticlassClassification.Evaluate(predictions); 1545using var predictionEngine = _mlContext.Model 1610IDataView shuffledFullImagesDataset = _mlContext.Data.ShuffleRows( 1611_mlContext.Data.LoadFromEnumerable(images), seed: 1); 1613shuffledFullImagesDataset = _mlContext.Transforms.Conversion 1619TrainTestData trainTestData = _mlContext.Data.TrainTestSplit( 1624var validationSet = _mlContext.Transforms.LoadRawImageBytes("Image", _fullImagesetFolderPath, "ImagePath") 1679var pipeline = _mlContext.Transforms.LoadRawImageBytes("Image", _fullImagesetFolderPath, "ImagePath") 1680.Append(_mlContext.MulticlassClassification.Trainers.ImageClassification(options)) 1681.Append(_mlContext.Transforms.Conversion.MapKeyToValue( 1686_mlContext.Model.Save(trainedModel, shuffledFullImagesDataset.Schema, 1692loadedModel = _mlContext.Model.Load(file, out schema); 1696var metrics = _mlContext.MulticlassClassification.Evaluate(predictions); 1704using var predictionEngine = _mlContext.Model 1765IDataView shuffledFullImagesDataset = _mlContext.Data.ShuffleRows( 1766_mlContext.Data.LoadFromEnumerable(images), seed: 1); 1768shuffledFullImagesDataset = _mlContext.Transforms.Conversion 1774TrainTestData trainTestData = _mlContext.Data.TrainTestSplit( 1781var validationSet = _mlContext.Transforms.LoadRawImageBytes("Image", _fullImagesetFolderPath, "ImagePath") 1813var pipeline = _mlContext.Transforms.LoadRawImageBytes("Image", _fullImagesetFolderPath, "ImagePath") 1814.Append(_mlContext.MulticlassClassification.Trainers.ImageClassification(options)); 1817_mlContext.Model.Save(trainedModel, shuffledFullImagesDataset.Schema, 1823loadedModel = _mlContext.Model.Load(file, out schema); 1826var metrics = _mlContext.MulticlassClassification.Evaluate(predictions); 1854IDataView shuffledFullImagesDataset = _mlContext.Data.ShuffleRows( 1855_mlContext.Data.LoadFromEnumerable(images), seed: 1); 1857shuffledFullImagesDataset = _mlContext.Transforms.Conversion 1859.Append(_mlContext.Transforms.LoadRawImageBytes("Image", fullImagesetFolderPath, "ImagePath")) 1864TrainTestData trainTestData = _mlContext.Data.TrainTestSplit( 1885var pipeline = _mlContext.MulticlassClassification.Trainers.ImageClassification(options); 1888_mlContext.Model.Save(trainedModel, shuffledFullImagesDataset.Schema, 1894loadedModel = _mlContext.Model.Load(file, out schema); 1897var metrics = _mlContext.MulticlassClassification.Evaluate(predictions); 1986using (var ch = (_mlContext as IHostEnvironment).Start("Ensuring image files are present.")) 1988var ensureModel = ResourceManagerUtils.Instance.EnsureResourceAsync(_mlContext, ch, url, destFileName, destDir, timeout); 2053IDataView data = _mlContext.Data.LoadFromTextFile(dataFile, new[] { 2060using (var tfModel = _mlContext.Model.LoadTensorFlowModel(modelLocation)) 2062var pipeline = _mlContext.Transforms.LoadImages("Input", imageFolder, "imagePath") 2063.Append(_mlContext.Transforms.ResizeImages("Input", imageHeight, imageWidth)) 2064.Append(_mlContext.Transforms.ExtractPixels("Input", interleavePixelColors: true))