allenhinson214
allenhinson214

Reputation: 165

MLMultiArray in CoreML

This is my first time trying to us CoreML and I am a little stuck on what to do. I built a model in python with Keras and Tensorflow that would take in information from a .csv file, break down that .csv file and extract only the closing information about a stock and the date for that close. It then runs a prediction and outputs an array of forecasted prices and an array of the forecasted date. I can then use this information and plot it onto a graph. To convert this model to coreml, I imported coremltools and ran this

mlmodel = ct.convert(model) mlmodel.save('converted_model.mlmodel')

Which it then converted the model and outputted a .mlmodel file for my to import into Xcode. However I noticed that the input it wants to take looks like this:

enter image description here

I am a little confused on how I can achieve the same outcome as I did in my python model with this MlMultiarray and what it means and how I can pass it into my input below:

enter image description here

Sorry if it is a simple fix, I tried looking at other solutions and it did not work. Thank you in advance!

Upvotes: 1

Views: 990

Answers (1)

Jeshua Lacock
Jeshua Lacock

Reputation: 6678

Check out Matthijs Hollemans' Swiftier MultiArray

It allows you to create a MLMultiArray like this:

var m = MultiArray<Float>(shape: [3, 4, 2])

And access a value like this:

let value = multiArray[z, y, x]

I've found Matthijs Hollemans' CoreML Survival Guide very helpful. In fact, his CoreML Survival Guide Sample has some information about MLMultiArrays.

If you have a more specific question I will try to help.

Upvotes: 1

Related Questions