Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coreML Failure Verifying Inputs

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?

like image 754
Russ West Avatar asked Jul 17 '26 16:07

Russ West


1 Answers

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

like image 134
Matthijs Hollemans Avatar answered Jul 19 '26 07:07

Matthijs Hollemans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!