Week 1

Ayush Agrawal
GSoC ’19
Published in
4 min readJun 5, 2019

From 27th May, Week 1 started and I must say that it has been nothing short of SURPRISES!!

I am starting to get a whole lot more feel of Swift for TensorFlow than I did before. It is becoming clearer to me how the API works and what happens in the background.

Paige was announced as Product Manager for TensorFlow. How awesome is that. Woohoooo!!! 🎉🎉🎉

This week, My 2nd converted notebook was reviewed by Richard and Brad. It was basically the first time that my code was reviewed by any professional coder. I got to know about these amaaazing developer practices one must abide to during code writing that I never knew of.

I was 🤯 (mindblown, in case you didn’t recognise the emoji)

Around 15–16 edits in the notebook and still going on…

In the meantime, I started working on the 3rd Tutorial based on Fashion MNIST Dataset. Everything is almost done as far as the Neural Net and Training Loop is concerned but the major problem that I am experiencing right now is that the data import pipeline isn’t currently as robust in Swift as it is in Python.

In simple words, I don’t have a way of simply importing Data in the same way as tensorflow_datasets.

I can access the Fashion MNIST directly from TensorFlow, using the Datasets API:

It’s that simple in Python. But in S4TF, it will take some time before something like this exists.

According to Brad,

The TensorFlow Datasets collection is a tremendous resource, but it might be a little while before an equivalent exists in Swift. At some point, it would be great to leverage the work done there for summaries, download locations, etc. to provide easy-to-load datasets in Swift.

You could possibly use TensorFlow Datasets using the Swift-Python interoperability, but you’d need to have a way of mapping a tf.dataset to a Dataset from the Swift API or to Tensors to pass into the Swift model.

I tried using Python Interoperability but still no luck in that. So, The only option that I have right now is download the dataset directly from the main GitHub repository.

I tried 2 methods for downloading it:

1.) Downloading a helper file that helps us work around some temporary limitations in the dataset API. You can find the helper file in S4TF’s Model Training Walkthrough

2.) Using urllib via Python Interoperability and download dataset through that.

Method 1 gets me the files, whereas Method 2 gives me a stack error. Weird! I’ll look into it sometime else. As for the files that Method 1 gives me, I think they might be incorrect somehow. Something fishy is going on.

Why I think that is because I tried using the Original MNIST Functions on those files. The Original MNIST Model is already implemented in S4TF, so I thought of using that on Fashion MNIST, since both the datasets are exactly the same in terms of properties.

It didn’t work! That model could not read the dataset.

I wrote 2 more methods to read the dataset but they also didn’t seem to work.

Method 1

Method 2

I asked Brad and he said that in Method 2, it looks like the number of floats I am reading from the MNIST source file doesn’t match the product of rowCount * columnCount (your Tensor shape there). rowCount being Int(labels.count) and columnCount being Int(images.count) / rowCount, that seems to indicate to him that images.count isn’t an even multiple of labels.count. Somehow, my integer division isn’t producing the right result there, so I should look deeper into why that is.

Let’s see how this goes further. Officially, I have till my 1st Evaluation to complete 2 more of these notebooks But I am hoping to complete all of the notebooks till my 2nd Evaluation so that I can work more on something else. But with these types of errors, I am not sure how much time they will take.

Apart from these notebooks, I am also working on something else too in S4TF which I won’t disclose now. If it’s successful, I’ll upload it in the same GSoC Project Repo along with the Steps and Documentation. If it’s not, maybe sometime else.

That’s all folks!

See you next week. Bye, bye 👋

--

--

Ayush Agrawal
GSoC ’19

Deep Learning Enthusiast | TensorFlow GSoC ’20 Mentor, GSoC ’19 Dev & GCI ’19 Mentor | BITS Pilani, India