Autogenerated CoreML class uses conflicting initializers

Viewed 207

I just upgraded to Xcode 10.0 which seemingly broke the CoreML autogenerated network class code. When building the project, I receive the error:

reg_net.m:94:50: No visible @interface for 'reg_netInput' declares the selector 'initWith0:'

Inside the class, the autogenerated reg_netInput initializer has the form initWith_0 but in the body of the prediction function, the code calls initWith0. I've tried to change the initializer names to be consistent but whenever I build, the code seemingly autogenerates again and reverts to the conflicting names.

I've also tried deleting and re-importing the .mlmodel files without success. Any ideas on how to fix this?

1 Answers

Try changing the input name(s) for your model by a valid identifier different than just a number "0".

Overview

In Core ML, a feature is a single input or output of a model. A model can have any number of input features or output features. Each feature has a name and a value type, which are defined in the feature's MLFeatureDescription. Model authors use feature descriptions to help developers integrate their model properly. Each MLFeatureDescription instance has read-only properties that indicate the feature's name, its type, and whether it's optional.

For examples of features, see Integrating a Core ML Model into Your App. Note the three input features named solarPanels, greenhouses, and size, and the output feature is named price. All four features are of type Double.

An MLFeatureDescription may also include constraints, which specify the limitations of the model's input and output features. For each input feature, the constraints describe what values the model expects from your app. For each output feature, the constraints describe what values your app should expect from the model. You can also write code to inspect these descriptions before using the model in your app.

Topics Inspecting a Feature var name: String

The name of this feature.

See: MLFeatureDescription and MLFeatureDescription name

Related