DeepBeliefSDK now works on Android

android

Photo by Aidan

When I first released the DeepBeliefSDK for iOS devices, one of the top requests was for an Android version. I’m pleased to say, after some serious technical wrestling, you can now use the image recognition library in your own Android apps! Just download the github repository and run the Android sample code.

I wasn’t expecting the port to be as big a technical challenge as it turned out to be. The algorithm relies on some pretty hefty numerical calculations, and on iOS I was able to use the Accelerate framework, but I was surprised to find that there was no equivalent for Android. I ended up writing my own custom ARM NEON SIMD code, alongside the Eigen library for some linear algebra operations. There don’t seem to be any easy ways to use ATLAS or even OpenBLAS on Android unfortunately. Both have ARM ports, but don’t make it easy to cross-compile, and I couldn’t find any pre-built binaries. I’d love to see the porting happen, feels like a great Summer of Code project?

I also hit problems when I was porting multi-core code. I’m a big fan of OpenMP, and the official Android build chain recently added support for the framework, but if you call it from a non-main thread, it crashes. I could have tried the workaround mentioned in that post, but rebuilding the toolchain was a bit too time-consuming for this project. In the end I was able to do a decent job on multi-core processors, but it was a lot harder than I was hoping.

The final hurdle was profiling. I’ve been spoiled by the Xcode’s Instrument profiling tool, and the best I could find for the kind of native code I’m running is this injected library that outputs gprof timing information. I ended up resorting to the old standby of shotgun profiling – doing a binary search by commenting out blocks of code to understand where the time is going. I managed to speed up the classification to around 650ms on a Galaxy S5, but I’m sure with better visibility I can squeeze some more out in the future.

I think most of my issues came from going against the grain of the platform. On iOS, everything’s C-like compiled code, whereas that’s a special case on Android. Java/JVM is the default, so it’s not too surprising that the tools are focused there instead. I’m excited to see what folks build with this now it’s out there, I hope you have fun!

My Foo survival tips

foolion

A classroom lion from KiwiFoo

One of the joys of being involved in the O’Reilly world is the occasional chance to attend one of their Foo (Friend Of O‘Reilly) events. These tend to be invite-only unconferences, with the mothership FooCamp happening at the Sebastopol HQ, and other topic or region specific ones popping up around the world. Invites have an admirable bias towards newcomers, especially folks who wouldn’t normally appear on conference organizers’ radars, so I never count on getting one. When I do though, I move heaven and earth to make it, because every one I’ve attended has left me buzzing with ideas and energy. The people who go aren’t only smart, they’re picked because they’re do-ers, and a lot of my projects (like the iPhone tracking story) have emerged as collaborations with fellow campers.

I’ve always found the experience of mingling extremely hard on a personal level though. It’s hours of rapid-fire conversations (and sometimes heated arguments!) with a succession of complete strangers, and if I’m not careful I find myself quickly getting exhausted and longing for a hole to hide in. I’ve read the tips, but even after three or four camps, I never felt like I was managing as well as I could. This week I was lucky enough to make it to KiwiFoo, organized by the wonderful Nat Torkington and the awesome Jenine Abarbanel, and it went so well I wanted to capture some of what worked for me. Bear in mind this is all very personal, and I bet different strategies will work for you, but here are my approaches:

Don’t drink

I’m normally a social drinker, and in past camps have had a beer or two during the evening sessions to relax. This time I stuck to coffee, and I was surprised to find I was actually able to stay awake a lot longer and have more rewarding conversations. This is probably a very personal preference, in most situations I find booze a fantastic social lubricant, but keeping my brain engaged made the experience of chatting to all the interesting people I kept bumping into a lot less taxing.

Play Werewolf

I have an inbuilt skepticism of organized fun, which doesn’t always serve me well. I’d never actually played Werewolf, despite it being the centerpiece of every Foo’s evening entertainment. This time I joined in, and now I’m a complete convert. The level of backstabbing and general deception, disassembling and deviousness made it the perfect forum to get to know the other people around the table. I was singled out as looking “sneaky as fuck” in my first game, which wasn’t actually a disadvantage going forward, and proceeded to have a wonderful time alternately murdering and lynching the other folks around the table, and being lynched and murdered in turn. I can’t recommend it highly enough.

Sit alone at lunch

One of the hardest parts for me is meal breaks. It’s like being the new kid at high school, and I’m left staring at a room full of strangers all busy in conversation with each other. I feel intensely awkward trying to sit down and break into people talking, and when I’ve done it, it’s hard to jump in the middle of it all. Paradoxically what worked for me this time was sitting at an empty table, looking welcoming and letting people join me. I’m not quite sure of the dynamics that make this so much better, but it held for more than just mealtimes. At previous Foos I spent a lot of time concerned with how to approach people, but making myself approachable turned out to be a lot easier. I still tracked down people I really wanted to connect with, but also let myself hang out, relax and be visibly ready for a conversation, whether it was at lunch or just between sessions. This alone saved me a lot of energy, and led to some great chats I never would have had otherwise.

You don’t always have to talk

Part of the joy of Foo is that all the participants are also contributors. Almost everyone runs a session, and the sessions themselves are more like discussion forums than lectures. This can be a culture shock compared to typical conferences, so a lot of first-timers rightfully need encouragement to join in and not just be an audience member. In previous Foos though I’ve ended up being concerned when I don’t have much to offer during discussions, which has left me spending too much time thinking about how my experience touches on the topic and not enough hearing what other people are saying.

At KiwiFoo some of the sessions I got the most from were on Maori topics, where I’ve got very little knowledge beyond the basic history. By listening carefully, I was able to learn a lot from what the other participants knew, especially when it came to their lived experiences. I got a flavor for the richness and complexity of how an indigenous culture was adapting to, and altering, the rest of New Zealand, in a way I never would have been able to outside of that sort of forum. I was active, but actively listening, with only a few contributions where they made sense. It saved me a lot of energy, and I got a lot more out of it than I would have otherwise. So, if you’re a newcomer definitely push past your normal conference instincts to get involved in a lot of the sessions, but do give yourself permission to be a complete beginner in a few too, absorbing what the other participants are contributing.

Anyway, I hope these very personal notes are helpful, at least for coming up with your own strategies for getting the most out of FooCamps. They really are the most amazing get-togethers I’ve attended (SciFoo in particular was truly one of the highlights of my life), so if you’re lucky enough to get an invite, try as hard as you can to make it, and enjoy it as much as you can!

How to add a brain to your smart phone

[Update – You can now download the app for your iPhone!]

I am totally convinced that deep learning approaches to hard AI are going to change our world, especially when they’re running on cheap networked devices scattered everywhere. I’m a believer because I’ve seen how good the results can be on image recognition, but I understand why so many experienced engineers are skeptical. It sounds too good to be true, and we’ve all been let down by AI promises in the past.

That’s why I’ve decided to release DeepBeliefSDK, an iOS version of the deep learning approach that has taken the computer vision world by storm. In technical terms it’s a framework that implements the full Krizhevsky stack of 60 million neural network connections, with a customizable top layer inspired by the Decaf approach. It does all this in under 300ms on an iPhone 5S, and in less than 20MB of memory. Here’s a video of me of me using the sample app to detect our cat!

This means you can now easily build cutting edge object recognition into your iOS apps. Even the training on custom objects can be done on the phone. Download and build the sample code and judge the effectiveness for yourself. Then all you need to do is teach it the things you care about, link against the framework, and you’ve given your app the ability to see!

What an ARM chip designer taught me about my career

Almost twenty years ago, I was an undergraduate at Manchester University in the UK. I’d been lured there by the promise of being in the same room as Steve Furber, a key designer of the original ARM chip, and so spent a lot of my time on hardware courses in the hope of hanging out with my hero. After a couple of years I eventually plucked up the courage to have a few words with him over warm white wine at a departmental mixer, blurting out the first thing that came into my head, something about how chip designers didn’t seem to get good salaries. He told me “If you’re really good you’ll get paid well, it doesn’t matter what the field is“. I liked that advice, it gave me permission to focus on learning the craft of programming, in the hope that it would pay off down the line whatever my initial job decisions were.

That was lucky, because my job choices were terrible. My first professional job paid less than I made at the shelf-stacking one I took to make it through college, I wasn’t working on interesting technology or problems, the company itself was beyond chaotic, and I was an awful programmer. The only thing that kept me going was the hope that I was learning how to suck less. One of the bright spots was our lead engineer Gary Liddon, a ‘veteran’ of a very young industry. He scared the living daylights out of me, he didn’t have any patience at all for time wasters, but he made sure I had support as I tried to figure out how to do my job. He showed me the secret to debugging impossible crashes for example – just comment out half the code, see if it still happens, and binary search your way to the answer.

As I bounced between jobs, I tried to spot the people like him who were better than me and learn whatever I could from them. I made some idiotic career decisions (who moves to Scotland to find work?) but over time I found myself becoming more capable as a programmer, which gave me the chance to recover from those bad choices. I found that hanging out with smart people who could show me amazing new ways to build software makes me want to go to work too! Learning started as something I focused on for my career, but I found it made me happy as well.

I’m not much of a believer in life advice, I feel like I’m still groping in the dark myself, but Steve’s throwaway remark has served me well as a guide. At least focusing on getting better at what I do is something I have control over.

Five short links

fivecircles

Photo by Tanakawho

A convention for human-readable 128-bit keys – Another nice example of natural and computer languages colliding, found via lobste.rs, which I’m hoping might turn out to be a version of Hacker News without the Hacker News commentators. I’ll still be lurking on the HN submission page though, since there are a lot of good links being thrown into the woodchipper.

Speedtree – A store devoted to beautiful computer models of trees. I remember wasting many evenings on simple fractal models of trees as a kid, it’s wonderful to see how far the technology has come.

Questionable crypto in retail analytics – Hashes are a flimsy curtain around private information that organizations want to share publicly, and they almost always reveal a lot more than the publishers like to think.

Starship Troopers and the Killer Cuddle Hormone – CPUs are tough to understand, but our brains are a whole different level of kludge. A great piece on how oxytocin interacts with our propensity to lie.

Binary Boolean Operator – The Lost Levels – If history had been a little different, we’d have the ‘implies’ operator, which would definitely make some of my assert()’s more readable.