Swift for TensorFlow - Tutorials + Guides

Hi everyone!

I am a Google Summer of Code participant with TensorFlow this year, and my project is to focus on building a collection of beginner and intermediate S4TF tutorials + guides. As part 1, I am to convert TensorFlow’s Udacity course materials (~11 Jupyter notebooks, currently implemented in Python) to Swift. These notebooks could be used in a future course, specifically targeted at mobile app developers (“Intro to Machine Learning with S4TF”).

I’ve begun working on it and have completed 2 notebooks as of now, and I will be implementing more as per my proposal.
Here is a link to the GitHub Repo: https://github.com/Ayush517/S4TF-Tutorials
Here is a link to the Medium Repo: https://medium.com/gsoc-19

I am very veryy excited to work on this projects. :smiley:
Always open to feedback and suggestions


8 tutorials already, nice work @Ayush517

cc @dynamicwebpaige

2 more in a pending PR and 2-3 more in the making.

Please do let me know how they are too :slight_smile:


Hey Thank you! These are really cool.

Hi, I recently learn about Swift for TensorFlow and before jumping and learning lots of new stuff (I don’t know swift) I still struggle to understand the basic questions like:

  • why choice of swift and not Go, Rust, or any other language(s)
  • how swift can help to deploy ML models to production environment, e.g. once we build and run it, how to integrate it with other legacy code running in (web) servers, etc.
  • any benchmarking numbers to convince its standing wrt models implemented in Python libs/frameworks, C++ TF, Go TF implementation?
    Basically, I think it should be nice to have a good tutorial answering these basic questions to provide convincing arguments about why Swift is a good choice for TF. I did listen to Swift for TF talk (https://www.youtube.com/watch?v=s65BigoMV_I), I did read (briefly) fast at blogs and whatever I find on internet but honestly I still can’t answer those questions.

Here’s the document that describes why Swift: https://github.com/tensorflow/swift/blob/master/docs/WhySwiftForTensorFlow.md

That “docs” folder has many other interesting documents too.

thanks, it is a good start. What about deployment? Do we have any documentation how to deploy swift based code into web server, mobile apps, etc. Basically we need examples not only how to write ML code, but how to integrate it with the rest of the infrastructure.

I haven’t really looked at S4TF in a while but deployment didn’t seem to be much of a concern back then. Until the changes for S4TF get moved into the official Swift repo, I don’t think you can use it for mobile apps (on iOS at least) because it might depend on features of the Swift runtime that are not present on iOS. But I don’t know what the current state of affairs is.

We have deployed S4TF on servers, NVidia Jetson devices, Windows, macOS and even Android apps, and some folks in the S4TF community have also put together some macOS apps powered by S4TF. Check out some of the maintained examples in: https://github.com/tensorflow/swift-models Hope that helps!