The WebNN API is a builtin browser API - that enables web applications to perform machine 'learning inference' with high efficiency. It allows you to leverage hardware acceleration for neural network computations directly within web browsers (no need to install anything - the browser has it builtin).
WebNN has been in development since 2021 - with the First Public Working Draft published on June 22, 2021. The current version is now almost stable with very few changes.
The official documentation and details for the API are online (free and open source):
https://www.w3.org/TR/webnn/
What if you don't have WebNN? You can still run Machine Learning projects in your browser - but you'll have to depend on external libraries - load them on the fly - ome popular web libraries for machine learning that you can use in a browser:
As WebNN has been around since 2001 - there are lots of examples online - but most of them don't work - as the API has been through a number of changes - with API member functions getting renamed - this has caused a lot fo the online demos to `fail` - not constantly updated and maintained so they don't work anymore. It's a shame - but it's just the way things are with new API standards.
I've provided a few complete minimal working exaples below you can work through to get started - they run in a browser with out any external resoures - you can train them in a browser.
Example of training a neural network using Synaptic (iteratively watch the training) - uses a 1-17-17-1 network using ReLU. We save it out to a JSON and load it into the WebNN to use the trained network.
A crucial point about WebNN - it's not the same as TensorFlor or Synaptic - it was primarily developed as a resource for `running` neural network projects (not training them). Hence, the WebNN is only half an API - no real training resources! So if you want to train a complex network - you can't do it! Instead you have to do thatin Python or another library - then save the trained network and load it into the WebNN.
As the official documentation says - WebNN is designed for neural network inference rather than training because it focuses on efficiently running pre-trained models in web applications. This allows for real-time AI tasks like image recognition and speech processing directly in the browser, without the need for server communication.
Personally, I think it was a bad decision to have WebNN focus on `inference` only - they could have had both! It would have made the API a much more attractive one stop solution for learning and developing solutions. Since you're downloading the trained model - it means you can download tensorflor or another library that would use WebGPU and do both and more - while WebNN is limited. Anyhow, it's too late now! They should have been more open minded and ambitious.
Visitor:
Copyright (c) 2002-2025 xbdev.net - All rights reserved.
Designated articles, tutorials and software are the property of their respective owners.