# Hand-coded neural networks

Here’s a JavaScript function that
returns a positive value if both `x`

and `y`

are positive:

```
function bothPos(x, y) {
const negX = Math.max(0, -x);
const negY = Math.max(0, -y);
return Math.max(0, 1-negX-negY);
}
```

Surprise - this function is also a neural network! Neural networks are usually drawn as

No, the neural network is not a series of neurons; it’s a JavaScript function which uses a restricted set of operations.

It approximates the function below, which is perhaps how you might naturally implement it:

```
function bothPos(x, y) {
return x > 0 && y > 0 ? 1 : 0;
}
```

Hear “neural network” and you probably think “machine learning”. But it’s useful to think of neural networks independently of machine learning.

With Vidrio

With generic competitor

### More by Jim

- Smear phishing: a new Android vulnerability
- A probabilistic pub quiz for nerds
- Time is running out to catch COVID-19
- The inception bar: a new phishing method
- The hacker hype cycle
- Project C-43: the lost origins of asymmetric crypto
- How Hacker News stays interesting
- My parents are Flat-Earthers
- The dots do matter: how to scam a Gmail user
- The sorry state of OpenSSL usability
- I hate telephones
- The Three Ts of Time, Thought and Typing: measuring cost on the web
- Granddad died today
- Your syntax highlighter is wrong

Tagged #programming, #machine-learning. All content copyright James Fisher 2019. This post is not associated with my employer. Found an error? Edit this page.