Skip to content

Comment on Keras.js – Run trained Keras models in your browser

Comments

This is awesome! Can you describe how you implemented the WebGL ops a bit more? Did you have to write your own convolution kernel with GLSL for example?

Thanks! For WebGL, credit goes to https://github.com/waylonflinn/weblas. I only really use GEMM, but it works quite well. In keras.js, convolution is implemented with the oft-used im2col transformation to turn it into a matrix multiply followed by reshape. Convolution kernels directly GLSL could potentially provide speed gains I'm sure, but I can't even imagine writing it for tensors of arbitrary shape.

Check out the Winograd optimisations used in Nervana's neon - very fast

https://www.nervanasys.com/winograd-2/

They mentioned they used the weblas library/module.

See code for example https://github.com/transcranial/keras-js/blob/master/src/Ten... or code on weblas github repo.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.