我将 ONNX 模型转换为 mlmodel,但无法使用预测功能。这是我的模型的输入和输出:[在此处输入图像描述][1] [1]:https://i.stack.imgur.com/6mY4H.png
我正在初始化模型和输入,如下所示:
var model: dont_touch_model!
var modelInputVector = try! MLMultiArray(shape: [1,1,13], dataType: MLMultiArrayDataType.float32)
我用这样的运动数据填充向量:
modelInputVector[[0, 0, 0] as [NSNumber]] = deviceMotion.userAcceleration.x as NSNumber
modelInputVector[[0, 0, 1] as [NSNumber]] = deviceMotion.userAcceleration.y as NSNumber
modelInputVector[[0, 0, 2] as [NSNumber]] = deviceMotion.userAcceleration.z as NSNumber
我尝试执行预测:
let modelInput = dont_touch_modelInput(sequenceinput: modelInputVector)
var modelOutput = try! model.prediction(input: modelInput)
我收到此错误消息:
"Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"
有人可以帮忙吗?