The demos can be used in two ways depending on your workflow. You can run it instantly on JT by simply
clicking 'View Demo', which opens the page directly in your browser with no setup required. Alternatively,
if you want to test or modify the demo in your own environment, click 'Download Demo' to save the HTML file
locally. You can then upload it to your localhost server and run it there, giving you full control to
experiment, debug, and integrate it with your own setup.
To begin, open Browser Developer Tools (DevTools) which is essentially an entire debugging suite built into
web browsers; you can typically open it with 'Ctrl + Shift + I'. We will use DevTools to inspect the browser
console logs for some demo sections.
This exercise will demonstrate how to train a basic neural network. A training request is first constructed and sent to the server for training. After training completes, a JSON message containing the trained model is returned to the client and persisted into IndexedDB. The neural network for this exercise includes an input layer and an output layer - there is no hidden layer configured. Also, by default the activation function used within each network layer is 'linear activation'. There are only 2 input neurons and 1 output neuron; the network is trained to predict the sum of the input values for 4 separate training examples; this is a basic 'introductory' linear regression problem.
<!DOCTYPE html> <!-- Copyright (c) 2026 by Javaika Technologies -->
<html lang = "en-AU"> <!-- Set the primary language to en-AU -->
<head>
<title>Basic Training</title> <!-- Set the page title -->
<meta name = "robots" content = "noindex, follow">
</head>
<body>
<!-- Add the UI elements to the page -->
<div>
<button id = "button-1">Train</button>
</div>
<!-- Include the framework script tag -->
<script type = "module" src = "https://www.javaika.com/frame/web-neural@main/api.js"></script>
<script type = "module" src = "https://www.javaika.com/frame/web-persist@main/api.js"></script>
<!-- Run the demo as an ES Module -->
<script type = "module">
const button1 = document.getElementById('button-1');
// Initialize a shorter prefix for referencing.
const jwn = window.javaika.webNeural;
const jwp = window.javaika.webPersist;
// Initialize the developer token endpoint.
jwn.init({
tokenEndpoint: "https://www.javaika.com/pscript/jwt-access.php"
});
// Authenticate before using the framework.
jwn.requestToken({
framework: "web_neural" // Specify the framework for token issuance.
});
// Listener for button click event.
button1.addEventListener('click', () => {
let trainRequestBuilder = new jwn.TrainRequestBuilder();
let trainRequest = buildTrainRequest(trainRequestBuilder);
jwn.submitTrainingJob(trainRequest);
});
// Build the train request.
function buildTrainRequest(trainRequestBuilder)
{
let trainRequest = trainRequestBuilder
.addRoot(root => root.setType("train"))
.addConfig(config => config.setEpochs(70))
.addLayer(layer => layer.setNeurons(1))
.addDatasets(datasets =>
datasets.addTraining(training => training
.setInputs([[1, 2], [3, 4], [5, 6], [7, 8]])
.setTargets([[3], [7], [11], [15]])
)
)
.finalize(); // Finalize the training reuest.
return trainRequest;
}
// Authenticate callback handler.
function onAuthenticate(event)
{
jwn.refreshToken(); // Refresh the authentication token.
console.log('[Web Neural] Authentication received callback:', event);
}
// Initialized callback handler.
function onInitialized(event)
{
console.log('[Web Neural] Framework initialized callback:', event);
}
// Training completed callback handler.
function onTrainingCompleted(event)
{
const key = event.detail.key; const model = event.detail.model;
const options = {'storeName': 'web-neural', 'source': 'local'};
jwp.storeJsonRecord(key, model, options);
console.log('[Web Neural] Training completed callback:', event);
}
// Callback event after authenticate.
document.addEventListener
(
'javaika.webNeural.authenticate', onAuthenticate
);
// Callback event after initialized.
document.addEventListener
(
'javaika.webNeural.initialized', onInitialized
);
// Callback event after training completed.
document.addEventListener
(
'javaika.webNeural.trainingCompleted', onTrainingCompleted
);
</script>
</body>
</html>
Next capability: Discuss how to run inference over stored models in IndexedDB.