Energy Efficiency drives Predictive Coding in Neural Networks

December 29, 2023 | Comments

I don’t remember how I came across it, but this is one of the most exciting papers I’ve read recently. The authors train a neural network that tries to identify the next in a sequence of MNIST samples, presented in digit order. The interesting part is that when they include a proxy for energy usage in the loss function (i.e. train it to be more energy-efficient), the resulting network seems to exhibit the characteristics of predictive coding: some units seem to be responsible for predictions, others for encoding prediction error.

Why is this exciting?

  • It proposes a plausible mechanism by which predictive coding would arise in practice.
  • It shows an existence proof of this (well, two actually: one for MNIST and one for CIFAR images)
  • It lines up artificial neural networks to theses around predictive coding from Andy Clark etc.

I grabbed the source code, tried to run it to replicate, and hit some issues (runtime errors etc), so have forked the repo to fix these, and also added support for the MPS backend (i.e. some acceleration on a Mac M1) which sped things up significantly - see my fork here.

But lots of directions to go from here:

  • I’d like to reimplement this in a framework like Jax, both to simplify it a little and to check I really understand it (and Jax)
  • Does this approach work for more complex network architectures? For other tasks?

In the spirit of making it all run faster, I tried implementing early stopping (i.e. if you notice loss doesn’t keep falling, bail - on the basis you’ve found a local minima). Interestingly, it seemed that if I stopped too early (e.g. after just 5-10 epochs of loss not dropping) my results weren’t as good - i.e. the training process needs to really plug away at this fruitlessly for a while before it gets anywhere.

Ending 2023

December 28, 2023 | Comments

2023 brought enough disruption and disappointment that I struggle to look back on it with much warmth. At the same time, I’ve many reasons to be grateful it wasn’t worse.

The year started with my beloved manager leaving Google, and then the layoffs hitting. I found the latter shocking, partly because I’d never worked in a company which had gone through them before, but also because there seemed plenty of room for improvement in how they were done. I woke up one morning to find colleagues - including some loyal, talented, productive long-time employees who I felt epitomized Google culture - had effectively been vanished overnight. I’m still bothered by this; while I can understand that it might be necessary, the way it was done seemed to fall short of the high standards Google sets for itself elsewhere. I chatted to a friend who works at Facebook, and what they described of their own layoffs seemed more compassionate. It doesn’t feel good to be beaten by Zuck on empathy.

A few slightly rudderless months followed; my responsibilities were a little diffuse and I lost a little passion for a new mission my group had taken up. In May an opportunity came up to move when the Google Brain/DeepMind merger occurred, and I shuffled into Google DeepMind, where I’m working now. It’s been interesting to shift sideways into a slightly different culture, and I’m finding it often refreshing, sometimes exhilarating, occasionally exhausting - and on balance am very happy to be there. I work in our generative media group, which is an interesting place to be right now, and have taken on more management responsibilities, something I’ve been wanting to do for a little while. Much of my work this year was around music, which enjoys both particular complexities and opportunities. I remain grateful to be working at the coal-face of AI, this decade.

Life outside work was similarly chaotic. Works on our home are about to enter their second year, and we’ve, depressingly, had the “architect and contractor pointing fingers of blame at each other” stage. I am hopeful that this will all conclude in the first quarter of 2024 and we can forget about it. More positively, our roof is now festooned with solar panels and a huge battery sits on our garage wall, which together seem to more than cover our energy needs for 9 months of the year.

I continued practicing karate in 2023. In July a group from our dojo traveled to Okinawa for the 4-yearly gasshuku. It was conveniently held just a typhoon drifted across the islands, twice, blocking entry for some friends, delaying our exit as the airport closed down, and shutting down training - including, memorably, a third of the way into my shodan grading. I was not passed. When given the opportunity to conclude it via Zoom a few weeks later, I declined (on the basis that these things ought to be done in person), and am stubbornly resolved to return to Okinawa to do it again. I’ve enjoyed continuing to help out with the kids’ classes on Saturday morning, and find it quite fulfilling to see their concentration and coordination improve over the months. Under 7s are also surprisingly bloodthirsty. Our daughter also returned to class this year (having declared, age 4, that she was “done with karate”) and is both enjoying herself and becoming more physically confident.

Generally, exercise was OK: I’ll have run about 600km (vs a target of 750km, about the same as last year), done 120h of karate (vs a target of 150, up significantly from 2022), and cycled 3400km (vs a target of 3000km, again slightly up from 2022 - cycling to work most days really helps). Around that, a few lovely walks around Tahoe, Marin, Point Reyes, and Sussex, and some skiing with friends and their daughters. No significant injuries this year - something to be grateful for as I turned 50.

We spent another wonderful, glorious summer camped out in Worthing near Kate’s parents - our daughter getting grandparent time and being ferried around other friends and relatives, and I working in London during the weeks and seeing old friends at weekends. It was particularly fun to catch up with university friends from 30 years previously, back in Reading - and having fun in Reading is quite an achievement.

I traveled to Israel for the first time, and probably (given events) the last time in a while. Tel Aviv is a beautiful city - it has a wonderful faded Mediterranean feel to it, and was more lively and upbeat than I expected. I happened to be visiting during the pro-democracy demonstrations, wandered through their beginnings on the way to walk, and watched them from the nearby Google office. The situation there is horrific, and talking to friends and colleagues based there brings it closer, in some ways, than the front pages of newspapers can.

I’ll write separately about the cognitive science reading group I set up in February; outside of that, it was an OK year for reading:

  • A Computer Called Leo by Georgina Ferry; a birthday gift from Toby. tl;dr Britain invents an early computer to run tea rooms, then fails to capitalize on it and sells it to ICL.
  • The Three Body Problem trilogy by Cixin Liu; wonderful, I read the first and devoured the following two, then watched the Tencent adaptation.
  • The Night Ocean, by Paul LaFarge; a wander through nested narratives and frequent fabrications based around a Lovecraftian scenius, with Asimov and Burroughs hovering at the edges.
  • Werner Herzog, a Guide for the Perplexed; a biography of the great man (who I got to see speak in San Francisco this year), spread over decades of conversation, the spirit shining through them all.
  • The Ballad of Halo Jones. Alan Moore knows the score; not read since I was a child, and so much had gone over my head back then. “What did she want? Everything. Where did she go? Out.”
  • Aurora, by Kim Stanley Robinson. Solid science fiction about the folly of interstellar colonization and sacrifice.
  • All You Need to Know About the Music Business, by Donald Passman. Great insider view (Passman is a music industry lawyer) of the byzantine history and practices of the music industry, including the changes wrought by streaming. Recommended by a colleague.
  • Do/Interesting, by Russell Davies. A slim gateway drug to Zettelkasten (notice stuff, collect it by writing it down, go through it), but with the goal of creativity rather than the (more common) sceintific efficiency.
  • A Visit from the Goon Squad and The Candy House, both by Jennifer Egan. Enjoyable, character-driven narratives about music industry workers and has-beens, bleeding into near-term science fiction, especially in the latter. Great fun, some beautiful set pieces. Who among us hasn’t tried screaming at strangers to force them into authenticity?
  • The Planiverse, by A K Dewdney. When I was about 8 years old, a family friend and maths professor showed me this book, which posited a 2-dimensional world. This year I tracked it down, read it and enjoyed it.
  • The Mountain In The Sea, by Ray Nayler. Christmas present from Kate; tl;dr what if octopuses got smart? A fun romp, but not so subtle - definite shades of Garth Merengi. Maybe I’m a bit too close to/interested in the source material.

Started and unfinished:

  • The Idea Factory by Jon Gertner. A history of Bell Labs. I was looking at models for past research organizations. Now I’ve joined a new one, I’m less interested.
  • Musicophilia, by Oliver Sacks. Great exploration of mental illness and music, I’m working through it still.
  • The Come Up. Christmas present from James, an oral history of hip hop. Really enjoying it but only just started.
  • You Have a Choice. Manual for self-pitying ingrates like myself, trapped in enjoyable demanding jobs yet still incapable of being happy. May never finish this one.

Things I’m thinking about for next year: improving my diet, retaking shodan, working from home a bit more, finding time for side-projects, Neuromatch Academy, spending the summer or more in the UK, and writing more here…

San Francisco Cognitive Science Reading Group, 2023

December 27, 2023 | Comments

So back in February I set up a local reading group for cognitive science. I’d wanted to learn more about the less… silicon… aspects of intelligence for a while, and figured getting together with a group of like-minded people was a good route to that. And I was surprised at how dead the existing meetups were, post-COVID. So I started one.

So far, so good. We’ve tended to gather a group of 4-5 each month, mostly face-to-face (we’ve had a couple of dial-ins). We alternate reading books and papers, to give us more time for the former. Our group is mostly the same each month, with maybe one or two new faces - we’ve not been great at retaining new arrivals. Conversations frequently get back to large language models, a topic I like to avoid given my day job, and how hard it is to keep track of what’s public and what’s not, when your entire working life is spent in this stuff. Karl Friston also shows up, metaphorically, most months. We need to spend some time with him, metaphorically, in 2024.

  • March: Being You: A New Science of Consciousness by Anil Seth. A physicalist (and more importantly, Sussex prof) presents an agnostic view of consciousness, emotion, free will, AI. Comforting confession that noone understands Friston on Free Energy, and I enjoyed the explanation of Integrated Information Theory and the takedown of those free-will experiments showing brain intention to act can be measured before intention is conscious.
  • April: The neural architecture of language - Integrative modeling converges on predictive processing. The researchers pass sentences through language models (up to GPT-1) and people (having them read out sentences while FMRI’d). They found they could build predictors both ways, from hidden layers of each to the other - suggesting strong correlations, especially on next word prediction… suggesting it’s a core capability and there are parallels between how artificial neural networks and the brain do it.
  • May: Mind in Motion: How Action Shapes Thought, by Barbara Tversky. I had trouble with this one, frequently finding myself more confused after reading the author’s explanations.
  • June: Building Machines That Learn and Think Like People. Dates from pre-transformer era, so a bit dated. Lots of desire for intuitive physics abilities and intuitive psychology; emphasis on compositionality as a core cognitive ability (which I can imagine, but they present as necessary)
  • July: we took July off, as I was in the UK.
  • August: The Experience Machine, another Sussex connection, Andy Clark’s latest. He takes the predictive processing theories laid out in previous works a bit further, in talking explicitly about precision weighting - an attention mechanism - and connects sensing and acting more overtly.. A few chapters then go into implications of the theory elsewhere - with focus on psychiatry, medicine, and broader societal issues.
  • September: Whatever next? Predictive brains, situated agents and the future of cognitive science. A 2013 paper from Andy Clark - interesting to have read this after the book, I had a real sense of the core ideas being worked through here. One detail I enjoyed: his prediction (on p12) that each level of processing requires distinct units for representations and error. This is exactly what they found in /energy-efficiency/.
  • October: Seven and a half lessons about the brain, by Lisa Feldman Barrett. Her name had come up in past discussions and readings so many times that it felt necessary. I was a bit lost in this one, and wondered if something was lost or added in translation between her academic work and this (more pop science) book. She starts by taking down the notion of the triune (lizard/mammal/human) brain model, wanders through brains-as-networks and pruning/tuning (with the mother/daughter relationship presented as an example, which I found plausible but not convincing), then through social/cultural implications and to the idea of brains creating reality.
  • November: Biological Underpinnings for lifelong learning machines - a literature review of all the ways biology might inspire and address issues with systems that need lifelong learning (i.e. those beyond today’s common training/inference split). Broad, interesting - their reference to memories being maintained even while brain tissue is remodelled must rule out some mechanisms for storage? But their metaphor or forgetting as being “memory locations being overwritten” seemed a bit too silicon-like… There’s a theme of “replay of training data” throughout (random activations in the hippocampus used for rehearsal/generative replay). Working out what needs to be stored for replay seems important.
  • December: Models of the Mind: How Physics, Engineering and Mathematics Have Shaped Our Understanding of the Brain by Grace Lindsay. I was surprised how much I enjoyed this exploration of maths in biology - when I started it, it felt like another pop-neuroscience introduction but I found a lot of material which I’d not encountered elsewhere. Starts from the basics of neuron firing, zooming out to network assemblies, into the visual network, to information-encoding and then to the motor system - finally into real-world interactions, Bayesian predictions, reinforcement learning and ending with grand unified theories (e.g. Integrated Information Theory, Thousand Brains, etc., of which the author is quite openly sceptical). I was pleased to hear Pandemonium Architectures called out - their messiness still feels both biologically plausible, and underexplored given our leap to the clean abstractions of matrix multiplication. .

A fun year, I think. Towards the end I was definitely losing energy a bit (mostly thanks to the day job) but reading back I’m happy with the ground we covered.

Starting the San Francisco Cognitive Science Reading Group

February 11, 2023 | Comments

Painting of an octopus reading a book

I really enjoyed spending some time last year learning about cognition, and I didn’t want it to end there. Plus as we (kinda, sorta) come out of COVID, I wanted to start meeting other human beings - maybe even ones I didn’t already know.

After observing that Meetup groups seem to be a wasteland - huge member numbers but no activity in most of them - I’ve set up the San Francisco Cognitive Science Reading Group. We have a first event in early March, at which we’ll discuss Being You, by Anil Seth. I’m still working on a venue - it’ll be an in-person event, though if we can support remote attendees we will do so.

Register! Like and subscribe! Join us!

2022 Redux

January 03, 2023 | Comments

I wanted to write something about 2022, to get it out of my head before 2023 rolls over it. An odd year - disjointed, mostly by choice, and feels better in retrospect than it did at the time. I remember having a strong sensation throughout it that it never hit a consistent rhythm.


  • I’m still working in Google Research - it’ll be 5 years in my current role in May. My manager is about to become my All Time Longest Ever Boss - ssh don’t tell him, it’s going to be a surprise. We published a white paper and blog post about Private Compute Core, which might be the most important thing I’ve done? It certainly gave me a strong sense of mission; I spent 3 years setting up this and Android System Intelligence, before moving on to other things: audio and ambient sensing. I am grateful to be working in AI right now.
  • I took a 3 month break from work. It was great. I wrote all about it here.
  • I spent a few months volunteering for Rewiring America, helping with their Mayors for Electrification program. They’re an excellent organization and I love their work, their ethos and their people; but I didn’t feel I was actually getting much of any use done, or that I had a surfeit of time to throw into it.
  • I’m still doing advisory work for Small Robot Company. They’re doing technically difficult work to solve real problems in the real world, and hit some great milestones this year.


  • Overall good - I exercised on 282 days, and my resting heart rate, VO2, etc are all good (but I’d like my VO2 to be excellent).
  • Highlight: thanks to the purchase of a Yuba Boda Boda e-bike last year, I beat the cycling goal I’d set myself (~3200km vs 3000km goal for the year I think - grrr Strava for not allowing a historical view of goals). E-bikes are enormously fun, mine has quickly become my main mode of transport. When they break they’re less fun. One lesson from this year: buy a proper e-bike chain!
  • Midlight: I didn’t quite manage to hit my running goal of 750km (I think I made it to 620km), but I was plagued by a hip injury that I’ve had for a couple of years and only ended up fixing this year thanks to physical therapy, so don’t feel too bad about that. I’ve started doing longer runs (a 5.5km loop up and down Twin Peaks and a longer downhill 8.5km to work), and my times got better towards the end of the year, approaching what they were in my 30s.
  • Lowlight: I only did 75 hours of karate (vs a goal of 150). Partly because I was away, partly a series of injuries (toe, wrist, hip, chest…). I do feel like my sparring has become much more controlled this year. I’m planning to focus more on this in 2023, it could be an exciting year.
  • Notable mentions: I’ve started to spend more time walking in the countryside. I did a lot of this in Italy and back in the UK, but I’ve also gotten into the habit of taking the odd day off work, driving up to Marin or Point Reyes, and just having a wander.
  • Being Near That Age, I had my first routine colonoscopy - an introduction to the indignities of your twilight years, I guess. The prep was less pleasant than the actual event, which was under a general anaesthesia. I hadn’t had that since I was 17 maybe? I started counting backwards from 10, the crew laughed and said “we don’t do that any more but you can if you like”, then a vaguely metallic taste in my mouth and I was gone.

Books; I read 37 books in total this year, thanks in part due to time off, in part due to deliberate effort. I probably won’t read as much this year. Some of the best ones, a sentence of pith for each:

  • Being A Human by Charles Foster (sequel to Being a Beast, which I loved): tl;dr understand the human condition by pretending to be Neolithic
  • The Mortdecai Trilogy by Kyril Bonfiglioli: a friend recommended this to me 10 years ago and I kick myself for not having listened to them. Laugh-out-loud upper-middle class English shenanigans.
  • How to Take Smart Notes by Sönke Ahrens, after which I am Zettlekastening
  • Hand, Head, Heart by David Goodhart : tl;dr we overprivilege cognitive ability and jobs arising from it, relative to those in the manufacturing or caring professions. Goodhart also wrote The Road To Somewhere, which really helped explain the new cross-society divisions behind Brexit.
  • Lanny, by Max Porter, author of the incredible Grief Is The Thing With Feathers. Terrifying medieval England-spirit does terrifying things in English village, terrifyingly.
  • Metazoa, by Peter Godfrey-Smith; tl;dr how far down the tree of life does consciousness emerge? Seems like the closer we look, the further back it goes.
  • Scientific Freedom: The Elixir of Civilisation, by Donald Braben; tl;dr what’s the best way to fund foundational research? Cast the net wide, fund exceptional people without conditions, don’t have outcome-related goals. I read this, and others, to think a bit more carefully about my working life.
  • Slaughterhouse 5, Kurt Vonnegut. Just sad I hadn’t read it already. So it goes.
  • The Diamond Age by Neal Stephenson. Read on a whim after a tweet from Emad Mostaque saying “who wants to help build the book from this?”. Beautiful novel - nanotechnology, future Victorian nostalgia, centered around a magic book designed to teach a young girl how to be subversive.
  • The Prince of the Marshes and The Marches, by Rory Stewart. I became a big fan of his in the last few years after reading The Places In Between, about his walk across Afghanistan post-9/11. The first of these concerns his time as a regional governor in post-war Iraq, the second his relationship with his father.
  • The Self-Assembling Brain, by Peter Robin Hiesinger; AKA So You Thought Understanding The Brain Was Hard, Let Me Make It A Thousand Times Harder For You. Basically: brains are grown not laid out, and the process of growth - unfolding sequences, Komolgorov-style - is an efficient, wickedly hard to understand primitive for brain understanding.
  • What is Life, by Addy Pross; tl;dr where does life come from? Self-replication in an environment finite enough that you’re competing for resources, leading to specialization, competition, and (once life starts harvesting energy) take-off. Really wonderful book.

Other stuff:

  • I went back to the UK for my cousin’s 50th birthday in November. It had been a decade since I was in a pub with 30+ good friends, and it left me feeling nostalgic for those days: we’ve made some good friends in the US, but there’s something about a social circle which mostly predates adulthood… having one such friend visit for 10 days was also really quite wonderful, I may never get that length of contiguous time with them again.
  • I saw a lot of my dad this year - that November trip, a month working from the UK early in the year, a week in Italy, a trip for him to SF, and some sundry days passing through on work trips.
  • We tried to start some construction work (a basement remodel with a side order of structural, plus some solar panels), and I have now been initiated into the ways of local government. Obscure, opaque, slow moving. I haven’t gone libertarian, but am definitely mentally looking over my spectacles when someone suggests more services be government-run.
  • I’ve joined the School Site Council for my daughter’s elementary school, to start getting a feel for that side of local politics.
  • I started enjoying a couple of new podcasts: The Rest is Politics (Alastair Campbell and Rory Stewart giving insider views on UK and world politics) and Brain Inspired (excellent interviews with neuroscientists and AI types, with a good Discord for supporters).
  • Courtesy of James, I found Buck 65’s substack and bounced from there to a load of his music, which I’ve been loving - in particular Laundromat Boogie (a concept album about doing laundry), and two collaborations: The Last Dig and Bike for Three

  • 1
  • 2