During the TensorFlow Dev Summit talk about Swift for TensorFlow, one of the bullet points mentioned SavedModel export as a near-term project. I was curious about plans for that and other file formats, and would be glad to help with this implementation. I see loading and saving of weights / models to standard formats as a key next step in making this more viable for everyday use. Also, being able to write out things like TensorFlow events would enable integration with TensorBoard for monitoring and visualization.
Most of the standard file formats you have out there for deep learning model interchange are based on protobufs. These include:
- Caffe
- TensorFlow frozen graph
- TensorFlow SavedModel
- ONNX
- Core ML
as well as TensorBoard events. The Swift Protobuf project, hosted by Apple, provides an easy and cross-platform way of loading and saving binary and text protobuf files in native Swift code:
However, it's an external dependency that currently isn't part of the mainline toolchain. Are there plans to more tightly integrate this with the toolchain and / or deep learning APIs? I have Swift code that I've already written to parse Caffe models, and have been building out support for others. I'd love to be able to submit that as part of the deep learning API, but it depends on the Swift Protobuf framework and won't build without that dependency. The framework is pretty mature and fairly official (with support from developers at Apple and Google), so I don't think it would be all that controversial to bundle with the toolchain.
I know that the graph is serialized into a protobuf on the C++ side at compile time, but that seems to be a separate mechanism and wouldn't be something we'd interact with here (aside from potentially inspecting the graph for model export).
Having the ability to pull in pretrained weights makes training more practical (I wrote my own importer to enable my AlexNet transfer learning example), and having a one-step model.exportCoreMLModel(to:[URL]) method (as an example) would immediately make Swift developers targeting iOS pay attention to this. TensorFlow Lite uses FlatBuffer, so it'll be a little different as an import / export format, but having native protobuf support would open up a bunch of these file formats. SavedModel -> TFLite would at least be a pathway for Android, Edge TPU, and other TFLite developers as a first step.
I figured that the mention of TensorFlow SavedModels during the talk might indicate that there was a plan for protobuf integration, so I was curious as to the roadmap there. Again, I'd be glad to help with this, because I've done a bunch of work with Swift protobufs and model files.