tensorflow / swift

Swift for TensorFlow
https://tensorflow.org/swift
Apache License 2.0
6.12k stars 608 forks source link

How this projects relates to coremltools? #509

Closed elgalu closed 4 years ago

elgalu commented 4 years ago

Is it fair to say that, if using TF/swift one no longer needs https://github.com/apple/coremltools ?

BradLarson commented 4 years ago

Core ML Tools lets you convert TensorFlow, PyTorch, etc. models to the Core ML format, and provides utilities for testing and running Core ML models. Swift for TensorFlow is a ground-up rethink of how to build, train, and run machine learning models (and more) using differentiable Swift and accelerators.

The two serve different goals, and exist at separate points in the machine learning model pipeline. Swift for TensorFlow lets you build, train, test, and deploy machine learning models across a variety of platforms (Linux, macOS, Android, Windows). You typically use Core ML Tools once you have a trained model in TensorFlow, PyTorch, etc. and need to convert it for use with Core ML on iOS or macOS. The two can be used together (we've seen examples of models trained with Swift for TensorFlow, serialized to disk, and then fed into Core ML Tools).

There has even been work on writing directly to the Core ML protobuf file format to bypass Core ML Tools. However, we don't yet have a process for automatically serializing the graph structure of a Swift for TensorFlow model, so there isn't a direct path for going to a Core ML model at present. Also, only a subset of the models that can be built with Swift for TensorFlow will be able to be expressed in the Core ML file format.

In short, you'll still need Core ML Tools for converting from serialized models in TensorFlow, PyTorch, etc. to Core ML, but if you want to explore building and training models in Swift, feel free to give Swift for TensorFlow a try.