coreML 初窺

coreML 初窺

本文章主要介紹對於CoreML Foundation的簡單實用,不深入涉及Machine Learn(自己對於ML知識還很淺):

  • CoreML相關簡介

  • 例子使用講解


CoreML相關簡介

2017-06-06 Apple 在WWDC2017大會上推出CoreML框架

  • Core ML lets you integrate a broad variety of machine learning model types into your app. In addition to supporting extensive deep learning with over 30 layer types, it also supports standard models such as tree ensembles, SVMs, and generalized linear models. Because it’s built on top of low level technologies like Metal and Accelerate, Core ML seamlessly takes advantage of the CPU and GPU to provide maximum performance and efficiency. You can run machine learning models on the device so data doesn’t need to leave the device to be analyzed.

  • 以上內容大概翻譯過來就是:CoreML可以集成多種機器學習模型類型到您的應用程序。它除了支持超多30 layer的機器學習,還支持多種標準的模型,比如: tree ensembles, SVMs, and generalized linear models。它建立於底層的技術類似Metal 和 Accelertate,因此能最大的利用CPU和GPU提供性能和效率。並且您可以直接在設備上直接運行機器模型,不需要數據離開設備進行分析。


例子使用講解

  • 建立的工程導入CoreML 框架

  • 導入*.mlmodel, 通過Xcode可以看到這個mlmodel的相關信息,包括model的類型,作者,Model Class ,輸入參數,輸出參數等信息;這裏寫圖片描述

  • 根據Apple的說法,導入mlmodel後,Xcode也根據model信息自動生成一個自定義編程接口模型,可以用它來與模型交互的代碼。具體它什麼時候轉出代碼,目前我還沒找到。剛開始我根據它的swift例子編寫obj例子,我把mlmodel導入的時候,然後編譯了好久都沒看到自動生成的接口model,然後我就不停的command+b,突然我就能看到了。然後在我的一個新項目中,使用了另外一個mlmodel,編譯好久也還沒看到生成的接口模型。這裏比較奇怪,也還沒找到對應的說法,也可能是xcode問題,稍後會研究。

[1]: https://developer.apple.com/machine-learning/ apple關於machine learning的介紹

[2]: https://developer.apple.com/documentation/coreml/integrating_a_core_ml_model_into_your_app apple 關於coreML例子

[3]: https://github.com/hxming2919/IntegratingaCoreMLModelintoYourApp_obj 使用obj重寫apple coreML例子

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章