Developing CTC loss for Tensorflow.JS

Learn about the problem itself

Existing solutions

Tensorflow architecture

Develop a naive implementation

  • Have everything calculated in tensors
  • Keep everything you can in the GPU’s memory (in our case WebGL)

Test

  • matching inputs and labels should return a zero loss and zero gradiens
  • random noise inputs should produce “something” other than error
  • should handle single elements and batched elements
  • should run correctly with different length labels
  • running model.fit() with 10 epochs we should see a decreasing loss
CTC calculation for “CAT”

Refactor cycle

const result = tensorA.mul(tensorB);
  • tfjs only — just like you would do it in pure javascript, but somebody has programmed it for you. Sweet. Since modern JS engines are lightning fast, you’ll get surprised how fast this implementation can run
  • tfjs-wasm — the core is implemented in WebAssembly, so there’s a significant improvement on performance. Not all functions are supported though. It is by far the fastest one if you don’t use any CUDA-based
  • tfjs-node — kernel functions run natively on the processor, so you have the full power of your CPU, including the special instruction-sets you might have. However, usually you have to recompile Tensorflow from scratch to make use of it.
  • tfjs-webgl — kernel functions take advantage of the parallel processing capabilities of your GPU
Processing time of batch item

Summary

--

--

--

I design and build complex, heavily integrated IT ecosystems for the banking sector

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

John Snow Labs Partners with UiPath to Create an Integrated Solution for Data Extraction using…

Federated Machine Learning : The future of AI in a privacy-obsessed world

EFPN: Extended Feature Pyramid Network for Small Object Detection

Few-shot Object Detection in Practice

Deploying Machine Learning Models on Node.js

Bengali.AI Handwritten Grapheme Classification

Residual Networks — Deep Learning

[Data Project] Detecting Cracks In Concrete Image Sets (1)

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
Péter Harang

Péter Harang

I design and build complex, heavily integrated IT ecosystems for the banking sector

More from Medium

Adaboost classifier for face detection using viola jones algorithm

Walk Walk Fashion Baby: Creating a T-Shirt Generation Model

Machine Learning Optimization Methods and Techniques

A “Practical Data Science” Approach to Detecting Meteors with CAMS