Overview
Use Core ML to integrate machine learning models into your app. Core ML provides a unified representation for all models. Your app uses Core ML APIs and user data to make predictions, and to train or fine-tune models, all on the user’s device.
A model is the result of applying a machine learning algorithm to a set of training data. You use a model to make predictions based on new input data. Models can accomplish a wide variety of tasks that would be difficult or impractical to write in code. For example, you can train a model to categorize photos, or detect specific objects within a photo directly from its pixels.
You can build and train a model with the Create ML app bundled with Xcode. Models trained using Create ML are in the Core ML model format and are ready to use in your app. Alternatively, you can use a wide variety of other machine learning libraries and then use Core ML Tools to convert the model into the Core ML format. Once a model is on a user’s device, you can use Core ML to retrain or fine-tune it on-device, with that user’s data.
Core ML optimizes on-device performance by leveraging the CPU, GPU, and Neural Engine while minimizing its memory footprint and power consumption. Running a model strictly on the user’s device removes any need for a network connection, which helps keep the user’s data private and your app responsive.
Core ML is the foundation for domain-specific frameworks and functionality. Core ML supports Vision for analyzing images, Natural Language for processing text, Speech for converting audio to text, and SoundAnalysis for identifying sounds in audio. Core ML itself builds on top of low-level primitives like Accelerate and BNNS, as well as Metal Performance Shaders.
这里面有一些模块需要介绍:
加速模块:借助于加速模块,可以进行大规模的数学计算以及基于图片的计算。它对高性能进行了优化,还包含一些用C写的API,用于数组和矩阵计算、数字信号处理,以及其他计算。所以Core ML可以满足数学的密集型计算的。
BNNS(Basic Neural Networks Subroutine)基本神经网络子例程:
实现了神经网络,通过训练的数据,子例程方法和其他集合对于实现与运行神经网络很有帮助。
Metal性能着色器:
可以渲染高级三维图形,并使用GPU设备进行并行计算。它包含着色语言,Metal Kit框架以及Metal性能着色器框架。通过Metal性能着色器框架,Core ML可以借助GPU系列的硬件特性提升工作效率。
总体来说Core ML为设备性能进行了优化,占用的内存最少,消耗的功率最小。