Platform
Resources
Pricing
Sign in
Contact us
Tom Sugden
Workspace
Fork
Public
By
Tom Sugden
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
toes
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
wlrec
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
nfans
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
weights
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
neuralNetwork
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
weights2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
neuralNetworkWithMultipleOutputs
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
weightsMatrix
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
neuralNetworkWithMultipleInputsAndOutputs
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
weightedSum
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
elementWiseMultiplication
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
vectorMatrixMultiplication
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML