Deep Learning: Entering my first kaggle competition

Three weeks ago I discovered the course. They offer a practical deep learning course for coders where you get straight in to building neural networks. They provide a huge amount of support through wikis, forums, aws scripts and tooling, videos and book recommendations.

AI competitions

The first step in this AI course is building an neural network for detecting cats and dogs in images using keras. To make this easy you use an existing model called Vgg16. Yea I had no clue what any of those things were either. There is so much information in this first lesson. It took me three weeks part-time to get through it all properly, and I still didn’t go deep in to the maths. is a site that lists AI competitions (with serious prize money!). Anyone can enter, but you will be up against team from Baidu, Facebook and Google 🙂 Vgg16 is a 16 layer model that won a competition in 2014 for image classification.

To do the calculations quickly you’ll need a computer with a GPU. I used AWS for this. The course has some neat scripts that set up your EC2 instance and installs Anaconda. You need to go through an approvals process to get the AWS instance with a GPU.


Keras is a (high-level) library that sits on top of the TensorFlow or Theano libraries. It abstracts away the details of creating modular models that can easily be implemented, modified, trained and verified. It makes it easy to run your model on CPU or GPU and change the underlying deep learning library.

There is a command line tool for pulling down keras competition data.

pip install kaggle-cli

You’ll need to accept the T&Cs for the competition. You’ll need to do a forgot password if you signed up for with an OAuth provider. Use this password for the kg client.

Once you have the cli you download the data for the competition from kaggle. You have to put it into folders labeled cats and dogs because vgg uses folders to classify rather than filename. You have to follow the videos for all the details.

Finally you can run the following few lines and get a 97% accuracy. And that’s only from one learning epoch! This isn’t a great score these days and so they go in to refining the model further to get 99%+.

# do it
vgg = Vgg16()
# Grab a few images at a time for training and validation.
# NB: They must be in subdirectories named based on their category
train_batches = vgg.get_batches(train_path, batch_size=batch_size)
val_batches = vgg.get_batches(valid_path, batch_size=batch_size*2)
vgg.finetune(train_batches) = 0.01, val_batches, nb_epoch=no_of_epochs)

Found 23000 images belonging to 2 classes.
Found 2000 images belonging to 2 classes.
Epoch 1/1
23000/23000 [==============================] - 654s - loss: 0.3473 - acc: 0.9701 - val_loss: 0.1633 - val_acc: 0.9865

I entered an AI comp!


Kaggle DogsCats entry

The age of applied deep learning

Ok, so I have glossed over hours of learning new things and faffing about with aws, tmux, convolutions and back propagation to name a few of the things I hadn’t much experience with.

But just the fact that I can create a working model like this, trained to a specific categorization problem is something I never imagined doing. 99% of this is me using models developed by really smart people but that’s what most developers do every single day. We take libraries and tools and use them to ship business value.

For the first time it really feels like AI is now part of the developer’s toolkit.

get started now!…

Fuzzy friday S02E07

From lunch to acquisition, how Atlassian bought Trello .

Success stories from developers who started at age 35,40,45 .

Why Basecamp chose profit over venture capital.

How do you measure leadership? from YCombinator.

Folk musician Jesse had his Youtube account hacked and lost all hist fans and likes. No recourse from Google so he’s starting again. The power of internet giants to have huge effects on people’s is only growing.

Enjoy and thanks for reading!

Subscribe here:

Webstock 2017: A long summary

Web Stock is tech conference like no other, held in Wellington, New Zealand. Once again I left feeling energized and impassioned after listening to all the speakers on such a wide range of subjects.

These are my summaries and don’t even come close to describing the full scope and quality of each talk. Use only as a guide to hear more. I’ll add links when the videos are released. I also may have made mistakes transcribing this because my hand writing is terrible!

Day 1

Tim Kadlec (@tkadlec) – Unseen issues behind web development

There are parts of web development that we don’t always consider – access, security, performance. They remain “unseen”.

There are barriers to internet access you might not consider

  • Content – e.g. access to certain content is simply blocked in many countries
  • Culture – e.g. in parts of India women cannot own mobile devices because it is described as “dangerous to their well being”
  • Cost – e.g. see GNI below. Some refugees in Europe have to decide on contacting family members at home country or eating that day.
  • Infrastructure – e.g. Only one in five Tanzanians have access to power and that power is not reliable.

53% of people leave your page if load time is >3 seconds. will tell you how much of GDI it costs someone in poorer places to view your web site. will scan your site for security issues Axe can be used to check for accessibility issues

Not providing basic accessibility cost Target $6 million in a lawsuit. Basic stuff – no alt text, image maps, not using header structure.

Kim Goodwin (@kimgoodwin) – Use scenarios and storyboards

A scenario is “A plausible future story following a real person or persona from start to finish”.

We tend focus on stories in pieces of functionality but there are UX ‘purgatories’ in between our stories where the user is left hanging. i.e. Who owns the user when they are between organisational areas of responsibility.

User stories cause narrow thinking – we lose the big picture, what is the user trying to achieve e..g “User logs in” – a user never thinks, “shit I must log in to Facebook” they are always transitioning to something else.

Kim recommends lots of user discovery.

Meeting expectations in your scenario is not good enough. You should add something exceptionally good.

What would a thoughtful human do? Went through a detailed example of booking a flight using a personal assistant rather than an application. Think about how this experience would compare to your website. Spoke about being pragmatic when using these tools and spoke about obviously removing impossible things and converging on the parts of the scenario that you control or influence.

Nice simple graphic of thinking about a solution framed as “What can I provide to the next step in this process?”.

Lara Hogan  (@lara_hogan) – Performance

Gave lots of practical performance optimizations you can make.

We shouldn’t have performance cops. Everyone should think about performance.

She uses live side by side comparisons of their site loading along side a competitors to inspire people and their executive.

Also uses side by side live loading of the website on a large monitor screen for major global locations. They server the site from a New Jersey data center and this highlights how slow site load in Australia is compared to what their engineers see in New York.

Katie Dill (@lil_dill) – Considering UX on parts of the user journey you don’t directly control

Lots of positive examples of good UX from some New Zealand companies.

Questioning how you control the chaos in the parts of peer-to-peer products you don’t directly control. E.g. Air bnb hosts meeting their guests. Trade me sellers handling a purchase.

See the big picture – find out the whole user journey. Identify the parts you don’t control. Set the stage – set expectations. Make sure the user knows what they’re getting in the peer to peer transaction (Air BnB have done lots of research into what the user wants to see first on a listing detail).

Give the peers guard rails – prevent any of the peers from inadvertently creating shit experiences – used trademe seller guides as example here. Said to quiet YOUR brand here. E.g. on the Etsy store the peer sellers voice is loud, your brand is quiet. On air bnb profiles the Airbnb brand is quiet so the peer hosts personality is loud.

Keep it real – let peers be authentic. Example of uber ride where she was having a terrible day and the guy said “can I cheer you up?”. He turned on disco ball and some techno and made her day. Also gave examples of allowing video for Airbnb’s new travel experiences product rather than images because it would show more of the host’s personality and authenticity of the complex experience.

Arm your partners – Give the peers feed back. Showed the dashboard for air bnb hosts that offers suggestions how to make more money and help videos etc.

Some examples from listening to Car Talk –

Lisa Welchman (@lwelchman) – Being human in the digital age

This was about Staying Human. Lots of paraphrasing on my part here. She was far more poetic 🙂

While focusing on the details (font size, some library) don’t forget that when working on websites you are creating the most profound experience humanity has had so far.

Through the internet we are bringing a new age into being. It will be a reflection of ourselves and our beliefs (so don’t fuck it up).

Some mobile applications the UN produces directly saves lives. The technology you build can directly save lives.

Introduced me to Vint Cerf through some quotes.

We are creating new and replacing the existing systems and realities (political, shopping, health, everything). We can make them good or bad.

Don’t feel helpless about bad things happening in the world. We are on the cusp of an enormous shift in humanity. You have agency, you have power. In building the internet you have influence. Change won’t come without setbacks. It brings the worst people out of the woodwork because they are afraid their way of the world is being taken away. Keep changing the world.

Marcin Wichary (@mwichary) – Three examples with a surprising detail in their UX

Speaks about one of Charles Babbage’s machines, the pacman game and mouse pointers on text mode displays. How they all have incredible UX but it’s not well known.

  • The babbage machine had error states to show people that calculating machines were safe.
  • Pacman had incredible tweaks to make the game more friendly than anything that had come before.
  • Detailed how much time and effort went into a DOS program to have a smooth mouse movement. No technical need for it but it made the physical mouse disappear and the user’s hand became directly linked to the pointer.

Very entertaining and informative!

Sacha Judd (@szechuan) – If you look closely there are technical experts in places you might not expect them

I think this was the highlight of the day for me. Excellent content and delivery. Full talk here:

In general it was about diversity. It was themed around the fandom that One Direction has and how this has inspired non-coders to become self taught coders and media content producers (editing tumblr and wrdpress themes), movie editors, CSS editing, social media management, writing fan fiction. How all these people are perfect candidates for tech jobs but haven’t followed that traditional path.

She became part of the community,  gained some trust and then ran a survey. They are typically young women, they are full of self doubt – no formal education, didn’t know about tech roles – even the job titles, were told they shouldn’t go for tech roles.

Recommends hiring on ability (not just academic achievement)

Gave incredible examples of the things one direction fans did. They organised 55 million social media fans to basically get a single they wanted released.

Recommended – remove gender specific keywords – achievement based hiring (no resumes)

Ashley Nelson-Hornstein (@ashleynh) – Humanities x Technology

Apple ads never have tech specs. Focus on the experience.

Big homage to steve jobs. He was at the crossroads of tech and humanities.

Gave an example about Polaroid. Inventor removed complexity of taking pictures so people could focus on photography.

Never Alone video game took Iñupiaq legends so that kids who were being lost to technology were able to re-engage with culture – Spent years working directly with elders to make sure game matched their expectations.

Cal Henderson (@iamcal) – Emojis

Fascinating history and how they are displayed on various devices. Such a fantastic speaker. Highly recommend this one!

Patricia Moore

Unfortunately Patti was hit by a car in New Zealand but she still recorded a talk from hospital while waiting for an operation. She spoke about designing for humanity.

Day 2

Jonathon Colman (@jcolman) – Wicked Ambiguity and UX

It doesn’t matter whether your a developer, tester, designer – we’re all working to prevent ambiguity in the experiences we create.

Introduced Tame vs Wicked problems.

Some examples of wicked problems – Designing to communicate with aliens and designing to warn people in 10,000 years about radiation dumps.

We should embrace wicked problems. Thy ignite creativity and hep us to innovate.

Jared Spool (@jmspool) – Becoming an organisation infused with UX from top to bottom

Lots of practical advice on the various stages of how an organisation incorporates UX in to their systems and processes. Great talk. Highly recommended.

Spoke about Disney. How in 90’s their website UX was terrible. So bad user’s couldn’t tell which park they were booking a hotel for. Described the transformation from that company to the company that created the Disney magic band – a $1 billion UX project.

Your goal should be to have your entire team CEO down to individual contributors fluent in UX.

Some plays for getting your organisation to become design driven include…

Immersive Exposure. Understanding the user experience provides understanding of customer problems. Recommends everyone spends at minimum 2 hours every six weeks with customers doing UX testing. Have senior leaders listen in on customer tests and plot the customer happiness on a graph as they go through. Help get leaders to empathize.

Shared Experience Vision. Create an experience vision. Recommends 5 years ahead. Use to provide guidance for critical design decisions. Make sure everyone has a goal to march towards.

A Culture of Continuous Learning. Be retrospective.”Why did we fail?”. “What did we learn?”. Add a new item to every standup – “What did I learn yesterday?” Log the learning somewhere like a slack channel.

Lindsay Aitchison – Designing working spacesuits vs Hollywood spacesuit design

Lots of information about why spacesuits are designed the way they are and some of the difficulties and considerations for designing the Mars spacesuit.

Learned about perchrolates and why they’re going to be a problem on mars.

Janine Gianfredi (@alohaj9) – Bringing agile to government IT

Obama brought private sector technical experts in to government to fix This was very successful so they started the US Digital Service to bring private sector methodologies and people in to government. Some points for successfully introducing these methods to government were…

  • Hire and empower great people
  • Find the truth tell the truth – you have to be honest up the chain about the issues your facing.
  • Optimize for results not optics – press conferences and quarterly reports shouldnt drive the work being done. Only focus on fixing the real issues.
  • Go where the work is – break down walls. Talk to your customers.
  • Design with users, not for them – There was a wrong assumption in government that government departments couldn’t talk to the public directly to get feedback on digital products. This was wrong and they started doing UX testing.
  • Create momentum – If things are moving slowly, and they do in government, create your own momentum. Have weekly goals and hit them.

Jeff Gothelf (@jboogie) – Scaling agile, bringing agile to the entire organisation

We have different techniques in different disciplines to try to get a more startup-like culture. Product has lean, tech has agile and design has design thinking. Startups don’t have this problem because they’re startups. People just have to get shit done.

Enterprises do have this problem because there is a relatively infinite runway and less consequences when things do go wrong.

Lean and agile seem to fail at scale. Outside of small teams there isn’t really an appetite for agile or lean. It’s over complicated (see agile landscape v3) and we have complex process definitions like SAFE ( which are often taken literally therefore missing the point of the flexibility required for moving like a startup.

The answer is to scale principals NOT processes. Some principals to bring in to the organisation are…

Customer value = Business value

This might seem obvious in startups and smaller teams but it should be explicitly worked on  at scale. OKRs are a god way to provide focus. They should be qualitative, inspirational, temporal and actionable. Recommends a book Radical Focus for reading more about OKRs. Gave example of car dealer site OKR. A tactic for enterprise is to plan only in quarters. Software is too complex for yearly planning. Another tactic is to use horizon planning.

Value learning over delivery

Tactic for prioritizing learning include having pilot teams working in new ways to learn from. Use the best people in the organisation. Provide sandboxes and guard rails for the teams. Encourage creative experiments.

Radical transparency

Have transparency through rituals, through access to information, access to customers, access to business data.

Humility in all things

Keep a beginners mind. “Strong opinions, loosely held”. Do product discovery. Use an orbital model for product development support (1-2 hours / week from marketing, legal etc.). Use a modern staffing model. Do you need all the traditional roles and bureaucracy. Modernize your tech stack. If the tech wont let you scale agile then make it better.

All of this should be a top-down driven effort.

Indy Johar (@indy_johar) – We need to re-imagine our institutional infrastructure for the digital age

Democracy is not just “the vote”, it is a stack distribution of agency

Gave examples of digital era products Domus and Wiki house where the pans for furniture or housing are available online and local companies build and ship them to people. These are innovative ideas but the regulatory stuff around multi jurisdiction house plans doesn’t exist yet. We have ignored the red-tape problem.

When the industrial revolution was underway in Britain the British Standards Institute started along side of it because it was a necessary system. We need to look at the dark matter, the bits in between our digital products. We should focus on new regulatory infrastructure instead of creating new products as a thin layer on top of old regulatory systems.

We have been living in an age with the cult of the individual. Western children when shown a painting will immediately focus on the object. Eastern children will focus on the context and will only focus on object when questioned about it directly.

We focus too much on single causes for our social problems but often there are many causes. The problems are complex. There can be surprising results from non-obvious solutions. Example of a town growing food in every available public space. Depression rates dropped, unemployment dropped. But try saying to the tech community “We don’t need a tech fund, we need to grow cabbages” – people won;t take it seriously. Buying activities vs buying outcomes == depression drugs vs growing cabbages.

Darius Kazemi (@tinysubversions) – Doing tech for activists

  • Use simple stuff
  • Don’t recreate, mutate
  • Technology is terrible, avoid where possible

Genevieve Bell (@feraldata) – Talking to AI

Lot’s of thought provoking ideas presented as a list of questions we would ask AI

AI has lots of daddies but not too many mommies.

The name itself is a sign of its time. In the 50s “artificial” was a good thing. Not such a good thing now days. “inteligence” doesnt suggest much feeling. What would we call it today?

Anil Dash (@anildash) – Humane tech

The internet is moving regulation in to private companies. For the worst.

The modern internet is not an efficient market. Opaque algorithms cannot be regulated.

Stefan Sagmeister (@sagmeisterwalsh) – Why beauty does matter in everything

Modernist buildings are horrible to live in. The modernists themselves renounced their lack of beauty. Gave some great examples of how adding beauty to things changes the way people feel and think. Underpass where people used to piss all the time. Tey had $5k to prevent the urinating. Painted “Yes” on each side of the wall and it became a place where newly weds would do photos. From industrial train transport to the skyline park. There has not been a single act of crime on the skyline park.

How if NASA added beauty to their suit it could become a talking point for more funding. People like supporting beautiful things. How Air bnb and Etsy have bland sparse design. It could be more beautiful. Showed some of his own work.

Smart Bear Ready API: Custom headers per request

I recently had a problem where our test analysts use Ready API software from Smart bear but our API authentication does a custom hashing function on the content. For tests to work we had to hash the entire request and apply headers for each test step.

There is an events hook in Ready API where you can add Java code to be run for event triggers. Unwrapping the content in the available request context API was difficult to figure out.

First open the Events dialog. Add a new event for RequestFilter.filterRequest to do something for every test step with a request.

Ready api event entry window

Here is the script.

import java.nio.charset.StandardCharsets;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.sql.Date.*; "=============================";
String apiUsername = "someApiUser";
String mySiteUsername = "";
String secret = "my special secret";

// set up some header names we will add to the request
String AUTH_HEADER_NAME = "X-mySite-Authorization";
String TIMESTAMP_HEADER_NAME = "X-mySite-Timestamp";
SecretKeySpec signingKey = new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA1");
String timestamp = new Date().format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("UTC")); "TimeZone.getTimeZone(UTC); " + TimeZone.getTimeZone("UTC").toString();
String requestResource = context.httpMethod.getURI();
String requestMethod = request.method;

// This is how you get access to the request content!
String requestContent = context.expand(request.requestContent); 'requestContent: ' + requestContent;

// AWS hashing algo start here
byte[] b = requestContent.getBytes("US-ASCII"); b.toString();
String signature="";
String bodyDigest = ""; 
try {
// Generate a body digest if there is content in the request
if (requestContent != null && requestContent.length() != 0){
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        byte[] digest = md.digest();
        bodyDigest = DatatypeConverter.printBase64Binary(digest);             
// Create a concatenated message string to sign
String message = new StringBuilder().append(requestMethod).append(requestResource).append(timestamp).append(bodyDigest).toString(); "Message: " + message;
// Get an instance of an HmacSHA256 hash and hash the message use the signing key
Mac mac = Mac.getInstance("HmacSHA1");
byte [] signatureBytes = mac.doFinal(message.getBytes(StandardCharsets.UTF_8));
signature =  DatatypeConverter.printBase64Binary(signatureBytes);
} catch (Exception e) {
    throw new SignatureException("Failed to generate HMAC : " + e.getMessage());

//log all the things for debug! "requestMethod: " + requestMethod; "requestResource: " + requestResource; "timestamp: " + timestamp; "requestContent: >" + requestContent + "<"; "apiUsername: " + apiUsername; "secretKey: " + secret; "============================="; "=====     HEADERS     ======="; "============================="; TIMESTAMP_HEADER_NAME + ": "+ timestamp; AUTH_HEADER_NAME + ": "+ apiUsername + ":"+signature; "=============================";

// Write out all the headers to the request context
// and add them to the test step
def headers = new StringToStringMap();
headers.put(AUTH_HEADER_NAME,apiUsername + ":"+signature);