-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
46 lines (42 loc) · 1.44 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!doctype html>
<html>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs/dist/tf.min.js"> </script>
<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js"> </script>
<head>
<script>
async function loadModel() {
model = undefined;
model = await tf.loadLayersModel("https://raw.githubusercontent.com/bhattbhavesh91/tfjs-model/master/model.json");
console.log("model loaded")
}
loadModel();
function make_prediction() {
var a, b, output;
a = Number(document.getElementById("first").value);
b = Number(document.getElementById("second").value);
input_xs = tf.tensor2d([
[a, b]
]);
output = model.predict(input_xs);
const outputData = output.dataSync();
document.getElementById("answer").value = Number(outputData[0] > 0.5);
}
</script>
</head>
<body>
<center>
<p>XOR Prediction Part 1</p>
<br>
</center>
<center>Enter the First number : <input id="first"></center>
<br> <br>
<center>Enter the Second number: <input id="second"></center>
<br> <br>
<center><button onclick="make_prediction()">Make XOR Prediction</button></center>
<br> <br>
<center><input id="answer"></center>
<br> <br>
</body>
</html>