Residual model from scratch with Tensorflow.js [Part 1]

What is a residual network?

First, I had a sequential convolutional network with a simple structure “convolution, convolution, max pooling, repeat, flatten it” like this:

Sequential convolution network VGG19
Residual connection called “identity”

Let’s write some code!

First I started with the article 18 Tips for Training your own Tensorflow.js Models in the Browser. There are plenty of good advice, but there are 2 problems I eager to eliminate:

  • There are code snippets, but no big picture in the end. It’s unclear how to put it all together
  • 2 years after it’s a bit outdated

Moving from tf.sequential()

Let’s create a simple convolutional network and convert it into one using tf.model()

Simple residual connection

Probably you can already guess that there is tf.layers.add() that we could use the same way. And you are right!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yury Kozyrev

Yury Kozyrev

Former Yandex Software Engineer, passionate Engineering Manager in Berlin