AI on Bitcoin

Perceptron as an Example

sCrypt
3 min readMay 14, 2021

Artificial intelligence, especially in the form of machine learning, has recently seen tremendous advances, with applications ranging from face recognition to autonomous vehicles. We propose to combine AI with the Bitcoin blockchain, for many salient advantages unachievable otherwise¹:

  • Open and transparent: both the code and data on the blockchain are public and can be verified by anyone and thus be trusted.
  • Collaborative datasets: everyone can contribute data and access the published data, compared to traditional siloed datasets.

Not only can Bitcoin maintain the datasets on chain for input into AIs, it can also host an AI algorithm itself to work with these datasets².

We have implemented a basic building block of machine learning, Perceptron, and demonstrated the enormous potential of building AI on Bitcoin.

Perceptron

Similar to neurons as the building blocks of neural networks, perceptrons are its equivalent of Artificial Neural Networks (ANNs). A perceptron is a single layer neural network, looking like the following

Perceptron

It consumes multiples inputs, weights them, sum it, feeds it into a step function (shown below) and produces one binary output (just 0 or 1). Perceptron is usually used to classify data into two categories.

Step Function

A Gender Classification Perceptron

We use perceptron to solve a simple classification problem. The inputs are the heights and weights of multiple people, the outputs are their genders.

Red markers indicate Males and Magenta Females

We aim to fit a boundary line that separates all the male samples from the female ones. Perceptron is a great way to find the line when samples become humongous.

We have implemented such a perceptron as a stateful contract. Its state consists of all the weights and the bias (w0 in the diagram). Initially, they are assigned some random values, which are then adjusted every time a transaction updates the state. The learning phase runs till the it converges.

Perceptron Contract

The final boundary found by our perceptron looks like this.

Gender Classifier Perceptron

Summary

Once we have built perceptron as basic blocks, more advanced and practical ANNs can be built atop Bitcoin, opening up endless opportunities.

--

--

sCrypt
sCrypt

Written by sCrypt

sCrypt (https://scrypt.io) is a web3 development platform specialized in UTXO-blockchains like Bitcoin

No responses yet