featurizeImage:機器學習影像特徵化轉換

使用預先定型的深度類神經網路模型將影像特徵化。

使用方式

  featurizeImage(var, outVar = NULL, dnnModel = "Resnet18")

引數

var

包含擷取像素值的輸入變數。

outVar

包含影像功能的輸出變數前置詞。 如果為 null,則會使用輸入變數名稱。 預設值是 NULL

dnnModel

預先訓練的深度神經網路。 可能的選項包括:

詳細資料

featurizeImage 會使用特定預先訓練的深度神經網路模型將影像特徵化。 此轉換的輸入變數必須是擷取的像素值。

定義轉換的 maml 物件。

作者

Microsoft Corporation Microsoft Technical Support

範例


 train <- data.frame(Path = c(system.file("help/figures/RevolutionAnalyticslogo.png", package = "MicrosoftML")), Label = c(TRUE), stringsAsFactors = FALSE)

 # Loads the images from variable Path, resizes the images to 1x1 pixels and trains a neural net.
 model <- rxNeuralNet(
     Label ~ Features,
     data = train,
     mlTransforms = list(
         loadImage(vars = list(Features = "Path")),
         resizeImage(vars = "Features", width = 1, height = 1, resizing = "Aniso"),
         extractPixels(vars = "Features")
         ),
     mlTransformVars = "Path",
     numHiddenNodes = 1,
     numIterations = 1)

 # Featurizes the images from variable Path using the default model, and trains a linear model on the result.
 model <- rxFastLinear(
     Label ~ Features,
     data = train,
     mlTransforms = list(
         loadImage(vars = list(Features = "Path")),
         resizeImage(vars = "Features", width = 224, height = 224), # If dnnModel == "AlexNet", the image has to be resized to 227x227.
         extractPixels(vars = "Features"),
         featurizeImage(var = "Features")
         ),
     mlTransformVars = "Path")