8 ms·
Keras.js – Run trained Keras models in your browser
- zan2434 10y agoThis 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?
- ilaksh 10y agoThey mentioned they used the weblas library/module. See code for example https://github.com/transcranial/keras-js/blob/master/src/Tensor.js https://github.com/transcranial/keras-js/blob/master/src/Ten... or code on weblas github repo.
- transcranial 10y agoThanks! For WebGL, credit goes to https://github.com/waylonflinn/weblas 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.
- dharma1 10y agoCheck out the Winograd optimisations used in Nervana's neon - very fast https://www.nervanasys.com/winograd-2/ https://www.nervanasys.com/winograd-2/
- deleted 10y ago[deleted]
- kiechu 10y agoThat's realy good stuff!
- lucidrains 10y agoThank you thank you! I love you
- aab0 10y agoWhat sort of performance can be expected compared to running in the terminal? How large NNs will this scale to in practice? I see a 50-layer resnet is mentioned; but not 1000-layers?
- augustt 10y ago1000 layer networks aren't used in practice. 50 layers is enough for state-of-the art performance.
- nl 10y agoIt sounds like inference (prediction) performance is ok (probably < 1 second for images with ResNet50). I doubt training performance would be very fun.
- transcranial 10y agoYou mean with tensorflow or theano as the backend? They have all kinds of optimizations that isn't possible to replicate here yet. There is certainly room for optimization! Also, 1000-layer resnets should theoretically be possible, but probably isn't that practical. Lots of exciting work happening in searching for more efficient architectures.
- dharma1 10y agoOn these demos, I'm getting several seconds on the imagenet inception v3 recognition on an i7 macbook pro (nvidia gpu), on both gpu and cpu modes. I've built tensorflow for android, running inceptionv3 trained on imagenet and it's much faster, running just on mobile CPU pretty much realtime, around 5fps. On a desktop CPU/GPU it's obviously even faster
- fbreduc 10y agocool but.. >Offload computation entirely to client browsers i'm not sure that's a big benefit really
- f00_ 10y agoThey're using pre trained models though, like https://github.com/heuritech/convnets-keras https://github.com/heuritech/convnets-keras I don't think they expect people to train them in the browser, just run the pretrained ones for image recognition or something
- matk 10y agoI agree. These are very marginal computation costs. This might have the most value as a Node transport though.
- dimatura 10y agoThis is great! The network visualizations are also pretty sweet. How are those generated?
- transcranial 10y agoThanks. Nothing fancy with the network architecture diagrams. The layers are just div elements with the layer name as the id. There's a definition of inbound/outbound connections by layer names, extracted from the keras json config, which is used to draw SVG paths.
- visarga 10y agoThis has teaching potential.
- dharma1 10y agoVery cool. Didn't work on Android (Chrome) either in GPU or CPU mode. Usual tricks like pruning the model and quantising to 8bit should get the model sizes down significantly from 100mb. Or using an architecture like squeezenet
- dguest 10y agoThis is awesome. We're trying to do something similar but moving in the opposite direction language-wise by implementing the models in C++: https://github.com/dguest/lwtnn https://github.com/dguest/lwtnn The idea is to have something lightweight that we can easily copy into our analysis framework (which is written in C++). If anyone reading this knows of a library that already does this it could save us some time.
- stared 10y agoIt does not work on my Firefox (but works on Chrome).
- oelmekki 10y agoThis is cool, especially given how javascript is everywhere. Is it browser specific, or could it run in other javascript environment, like nodejs?
- deleted 10y ago[deleted]
- matt4077 10y agoWonderful! And because all praise comes with work in OSS: I wish the network diagram would show intermediate states where possible. I've seen some examples where – with the right presentations – they gave fantastic insights into the network's "thinking".
- botw 10y agohow to get the demo running? they are just images now.