Public
Edited
Jul 24, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const input = [toes[0], wlrec[0], nfans[0]];
const prediction = neuralNetwork(input, weights);
return prediction;
}
Insert cell
{
const input = wlrec[0];
const predictions = neuralNetworkWithMultipleOutputs(input, weights2);
return predictions;
}
Insert cell
{
const input = [toes[0], wlrec[0], nfans[0]];
const predictions = neuralNetworkWithMultipleInputsAndOutputs(input, weightsMatrix);
return predictions;
}
Insert cell
Insert cell
weights = [0.1, 0.2, 0]
Insert cell
function neuralNetwork(input, weights) {
const prediction = weightedSum(input, weights);
return prediction;
}
Insert cell
weights2 = [0.3, 0.2, 0.9];
Insert cell
function neuralNetworkWithMultipleOutputs(input, weights) {
const predictions = elementWiseMultiplication(input, weights);
return predictions;
}
Insert cell
weightsMatrix = [
// #toes, %win, #fans
[0.1, 0.1, -0.3], // hurt?
[0.1, 0.2, 0.0], // win?
[0.0, 1.3, 0.1] // sad?
];
Insert cell
function neuralNetworkWithMultipleInputsAndOutputs(input, weights) {
const predictions = vectorMatrixMultiplication(input, weights);
return predictions;
}
Insert cell
Insert cell
function weightedSum(a, b) {
return a.reduce((m, d, i) => m + d*b[i], 0);
}
Insert cell
function elementWiseMultiplication(n, a) {
return a.reduce((m, d) => [...m, n*d], []);
}
Insert cell
function vectorMatrixMultiplication(vect, matrix) {
return matrix.reduce((m, d) => [...m, weightedSum(vect, d)], []);
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more