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")