简体   繁体   English

CoreML 中的 MLMultiArray

[英]MLMultiArray in CoreML

This is my first time trying to us CoreML and I am a little stuck on what to do.这是我第一次尝试我们的 CoreML,我有点不知道该怎么做。 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.我在 python 和 Keras 和 Tensorflow 中构建了一个 model,它将从 .csv 文件中获取信息,分解 .csv 文件并仅提取有关股票的收盘信息和收盘日期。 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.然后我可以使用此信息并将其 plot 绘制到图表上。 To convert this model to coreml, I imported coremltools and ran this要将此 model 转换为 coreml,我导入了 coremltools 并运行了它

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:然后它转换了 model 并输出了一个 .mlmodel 文件供我导入到 Xcode。但是我注意到它想要获取的输入看起来像这样:

在此处输入图像描述

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:我对如何使用此 MlMultiarray 获得与我在 python model 中所做的结果相同的结果以及它的含义以及如何将其传递到下面的输入中感到有些困惑:

在此处输入图像描述

Sorry if it is a simple fix, I tried looking at other solutions and it did not work.抱歉,如果这是一个简单的修复,我尝试查看其他解决方案但没有成功。 Thank you in advance!先感谢您!

Check out Matthijs Hollemans' Swiftier MultiArray查看 Matthijs Hollemans 的Swiftier MultiArray

It allows you to create a MLMultiArray like this:它允许您像这样创建一个MLMultiArray

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.我发现 Matthijs Hollemans 的CoreML Survival Guide非常有帮助。 In fact, his CoreML Survival Guide Sample has some information about MLMultiArrays .事实上,他的CoreML Survival Guide Sample有一些关于MLMultiArrays的信息。

If you have a more specific question I will try to help.如果您有更具体的问题,我会尽力提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM