Terraform and Azure Managed Identity

09 June

I love getting to a point with Infrastructure as Code (IaC) where not only are the resources reproducable, but also encoding good security and utilisation of cloud resources into the contents. Firstly, support in Azure Storage for Active Directory access control went GA and utilising this over an access key is one of those security considerations that seems could be automated. Secondly, managed identities are a fantastic way to get the power of Azure Active Directory without the process of keeping secrets and other management secure. Read the post

TensorFlow Serving with a variable batch size

10 May

TensorFlow serving can handle a variable batch size when doing predictions. I never understood how to configure this and also the shape of the results returned. Finally figuring this out, here’s the changes to our previous serving setup to accept a variable number of images to classify for our model. Serving input function First thing is to update our serving input receiver function placeholder. In the past we had set the placeholder to have a shape of [1], for variable batch size, this is as easy as setting it to [None]. Read the post

Saving money on GPUs in Azure

06 May

Azure provides low priority VMs that we can use to save some money when utilising GPUs for machine learning. All the major cloud providers offer spare compute for a discount: Google cloud has Preemptible VMs, AWS has spot instances and Azure has low priority VMs. On Azure these low priority VMs can only be provisioned in Azure Batch or virtual machine scale sets and we can use the latter for hosting a jupyter environment. Read the post

TensorFlow Serving our retrained image classifier

06 May Machine Learning

Here we’ll look at exporting our previously trained dog and cat classifier and call that with local or remote files to test it out. To do this, I’ll use TensorFlow Serving in a docker container and use a python client to call to the remote host. _Update 12th June, 2018: I used the gRPC interface here, but TensorFlow serving now has a REST API that could be beneficial or of more interest_ Read the post

Image classification using TensorFlow estimators and TensorFlow Hub for transfer learning

21 April

This notebook is available as a codelab TensorFlow Hub was announced at TensorFlow Dev Summit 2018 and promises to reduce the effort required to use existing machine learning models and weights in your own custom model. From the overview page TensorFlow Hub is a library to foster the publication, discovery, and consumption of reusable parts of machine learning models. A module is a self-contained piece of a TensorFlow graph, along with its weights and assets, that can be reused across different tasks in a process known as transfer learning. Read the post

My first Azure Batch AI Job

15 January Machine Learning | Azure

Azure Batch AI provides us the PaaS opportunity to use GPU resources in the cloud. The basis is to use virtual machines in a managed cluster (i.e. you don’t have to maintain them) and run jobs as you see fit. For my use case, the opportunity of low-priority VMs to reduce the cost of using GPU machines is also particularly promising. What I’ll run through is running our first job on Azure Batch AI. Read the post

Getting started with PowerShell and Azure on macOS

13 January

PowerShell 6.0 has now become generally available and with it the ability to use PowerShell cross platform. With all of its goodness, I was most excited about Azure powershell cross platform capabilities that this brings about. Firstly, the azure-cli is also a great cross platform tool, but sometimes the powershell capabilities seem to outshine this CLI. Installing PowerShell on macOS The installation instructions on the repo are pretty straight forward, but for summary: Read the post

Using TensorFlow Feature Columns in your Custom Estimator Model

02 January Machine Learning

The TensorFlow canned estimators got promoted to core in version 1.3 to make training and evaluation of machine learning models very easy. This API allows you to describe your input data (categorical, numeric, embedding etc) through the use of feature columns. The estimator API also allows you to write a custom model for your unique job, and the feature columns capabilities can be utilised here as well to simplify or enhance things. Read the post

Understanding TensorFlow's rnn inputs, outputs and shapes

06 December

Understanding the shape of your model is sometimes non-trivial when it comes to machine learning. Look at convolutional neural nets with the number of filters, padding, kernel sizes etc and it’s quickly evident why understanding what shapes your inputs and outputs are will keep you sane and reduce the time spent digging into strange errors. TensorFlow’s RNN API exposed me to similar frustrations and misunderstandings about what I was expected to give it and what I was getting in return. Read the post

Inspecting TFRecord files and debugging TensorFlow data input

02 December

TFrecord files are TensorFlow’s suggested data format, although they are very difficult to inspect given their binary nature. Inspecting the contents of existing record files and ensuring the data in your input pipeline is as you expect is a good technique to have. Inspecting TFRecord values The first trick is reading in the tfrecord files and inspecting their values in python. As you’d expect, the TensorFlow API allows this (although a little hidden down). Read the post

Azure GPUs, Jupyter and Machine Learning

30 November

I’m a big advocate of the cloud and it’s ability to provide just enough resources ad hoc. You can use whatever you want, and pay for it just when using it. In machine learning there are services such as Google’s ML Engine or Azure’s upcoming Batch AI but during development, data preprocessing etc sometimes you want immediate iterative processes. In these cases, you can’t go past a Jupyter notebook and in this case, running that on a VM. Read the post

Speeding up TensorFlow development and debug in terminal

29 November

For most of my development, I use Jupyter notebooks which are fantastic for iterative development, but running in managed environments such as Google’s ML Engine require python scripts. You can obviously run these locally with python in the terminal or your IDE, but the loop from debug, terminate, change and re-run is rather slow (from what I can tell due to import speed of tensorflow and other imported packages). I wanted to be able to keep these imports in memory (like Jupyter) and just re-run a single function during development. Read the post

Getting started with TensorFlow in Google ML Engine

28 November

In 2017, there seems no doubt that if you aren’t running your ML training on a GPU you just aren’t doing things right ?. At home, my only computer is my MacBook Pro which is great to develop on, but would take an extremely long time to train something such as an image classification task. Saying this, I’d love to have a GPU machine at home, but I also love the opportunity to use this hardware in the cloud without having to power it, upgrade it and generally take care of something you actually own. Read the post

TensorFlow serving with canned Estimator

31 October

I’ve had a few attempts at getting TensorFlow estimators into a serving host and a client I can use to query them. Finally getting it working, I thought I’d write up the steps for reproduction. Assumptions and Prerequisites The first assumption is that you have already trained your estimator (say the tf.estimator.DNNRegressor) and this is now in the variable estimator. You also have a list of feature columns as is standard in a variable feature_columns. Read the post

Using pre-trained Glove embeddings in TensorFlow

27 October

Embeddings can be used in machine learning to represent data and take advantage of reducing the dimensionality of the dataset and learning some latent factors between data points. Commonly this is used with words to say, reduce a 400,000 word vector to a 50 dimensional vector, but could equally be used to map post codes or other token encoded data. Another use case might be in recommender systems GloVe (Global Vectors for Word Representation) was developed at Stanford and more information can be found here. Read the post

MNIST with Tensorflow Experiments and Estimators

19 September

An MNIST classifier is the go-to introduction for machine learning. Tensorflow is no different, and evolves to the Deep MNIST for Experts to include convolution, max pooling, dense layers and dropout: a good overview of ML layers for image problems. The downside of this is it doesn’t make use of Tensorflow’s new tf.estimator high level APIs. These provide all sorts of benefits for free than the usual sess.run TensorFlow tutorials you see online. Read the post

Images with directories as labels for Tensorflow data

19 September

A common format for storing images and labels is a tree directory structure with the data directory containing a set of directories named by their label and each containing samples for said label. Often transfer learning that is used for image classification may provide data in this structure. Update May 2018: If you would like an approach that doesn’t prepare into TFRecords, utilising tf.data and reading directly from disk, I have done this in when making the input function for my Dogs vs Cats transfer learning classifier. Read the post

Convert and using the MNIST dataset as TFRecords

18 September

TFRecords are TensorFlow’s native binary data format and is the recommended way to store your data for streaming data. Using the TFRecordReader is also a very convenient way to subsequently get these records into your model. The data We will use the well known MNIST dataset for handwritten digit recognition as a sample. This is easily retrieved from tensorflow via: from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets( "/tmp/tensorflow/mnist/input_data", reshape=False ) We then have mnist. Read the post

Azure functions as static site host

05 September

Azure functions can be very cheap and very easy to manage. Hosting a single page app (SPA) that does very few requests to the host and is basically just a few files to be delivered to the client seems perfect for using the consumption pricing of azure functions. Basically only pay for a request vs a monthly fee. Azure Resources We’ll need a few resources in Azure, they are: Read the post

Ghost from an NPM module and hosted in Azure

02 August

It was great to see you can now use Ghost as an NPM module. The upgrade process used to be a pain prior to the 1.0 release. Saying this, I ran into a few bumps trying to host this on Azure. Follow the docs on Ghost as an NPM module to get started Set server port at runtime Node runs behind IIS and is reverse proxied so the port we are assigned is not static. Read the post

Xcode auto-increment build on archive

11 November iOS

Simple script to bump the build number of my Xcode project on each Archive. The version number I am leaving as a manual change for the moment, but each time I release a build to testers, I want the build to change and a commit message for the change. In Xcode from the menu go to Product -> Scheme -> Edit Scheme On the side, expand the Arhive build and select Pre-actions. Read the post

Machine Learning in Azure - Linear Regression

31 October

I recently completed Stanford Machine Learning on Coursera taught by Andrew Ng. It is a fantastic course for anyone interested, plus it’s free! The course uses MATLAB or Octave for the programming assignments. With the release of Azure Machine Learning, this seemed like a good exercise to reimplement these assignments on Azure ML to learn the tool. Creating an Azure ML Workspace To get started, you will need an Azure subscription. Read the post

Self-sizing UITableViewCell with UITextView in iOS8

01 October

Ever since watching the session ‘What’s New in Table and Collection Views’ from WWDC 2014, I have tried to create all of my tables and collections use self-sizing and update for dynamic typing. Straight from the presentation, this sums up a pretty good motivation: This strategy is really going to improve the way that we architect our table views, number 1, because you can encapsulate logic right in the cells, and 2, the fact that you can do that will make it so much easier to have cells that are not a hard coded compile time known height which means you can easily adopt the dynamic font changes. Read the post