let model = test2()
var data = [1.0, 2.0,2.0,2.0,2.0,2.0,2.0]
guard let mlMultiArray = try? MLMultiArray(shape:[1,7], dataType:MLMultiArrayDataType.double) else {
fatalError("Unexpected runtime error. MLMultiArray")
}
for (index, element) in data.enumerated() {
mlMultiArray[index] = NSNumber(floatLiteral: element)
}
guard let markupOut = try? model.prediction(input1: mlMultiArray) else {
fatalError("Unexpected runtime error.")
}
I’m using swift 4 and core ML.
Compiles but fails during run time with:
[coreml] Input input1 is an array of rank 2, but this model only supports single vector inputs (rank 1) or a sequence of batches of vectors (rank 3). [coreml] Failure verifying inputs.
input1 is type of MultiArray (Double 7)
Do I fix the "failure verifying inputs" error by converting the MultiArray of doubles to single vector inputs/ batches of vectors? If so how do I convert a MultiArray of doubles to single vector inputs or batches of vectors?
When you write shape:[1,7]
the MLMultiArray is of rank 2. Core ML says this model does not support rank 2 inputs. So either do shape:[7]
(to make it rank 1) or shape:[1,1,7]
(to make it rank 3).