Being smarter through smart life choices

We live in the age of the brain. While being smart has always been important for humans, being the major contributor to our evolution and cultural development, it has taken on a roll never before…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Running Deep Neural Networks on Bitcoin

Implement an On-chain Handwritten Digit Classifier

The network is made up of several components: neurons/nodes, connections, biases, and activation functions. These components are grouped together consecutively into layers. The first layer is called the “input layer”, where data gets passed into the network, and the last one the “output layer”, by which the network returns its output. A very simple neural network contains only these two layers. To improve the performance we can add one or more “hidden layers” between the two. Networks with hidden layers are called “deep neural networks” (DNN).

An illustration of a deep neural network

Each connection between neurons in the network is weighted with a specific value. Each neural also has a value called a “bias” which gets added to the sum of its inputs. Learning is the process of finding a set of these weights and biases, so that the network will return a meaningful output given some input.

The DNN for MNIST handwritten digits is made up of an input layer of 784 (28 x 28) nodes, a hidden layer of 64 nodes and an output layer of 10 nodes (number of possible classes/digits). The layers are all fully-connected, which makes the network contain a total of 501760 (784 * 64 * 10) connections.

The function predict() takes in the initial values of the input layer. In our case that is the serialized values of a handwritten image. It returns an integer which represents the classification result, i.e. the number on the image.

Because sCrypt does not support native floating point numbers, we use fixed-point representations by simply scaling values by 10⁸. For example, 0.86758491 becomes an integer 86758491. When multiplying two values we rescale the result, i.e. divide it by 10⁸.

DNNs like this could be used in many ways inside a smart contract. For example, you can train a model to recognize if an image contains a hotdog with a certain accuracy. Users are incentivised to scrape the Internet for such photos and automatically get paid in bitcoin micropayments for submitting them. These photos can be collected to train the model and improve its accuracy.

Add a comment

Related posts:

Pitching One Article Can Open Doors

I had no idea weeks ago I’d be pitching for a printed book. It’s not every day you’re offered a chance at a good chunk of change to write about something you love. Having that writing sold in stores…

Bibit Srikaya Tanaman Buah Situbondo

bibit srikaya tanaman buah Srikaya, adalah tanaman yang tergolong ke dalam genus Annona yang berasal dari daerah tropis. Buah srikaya berbentuk bulat dengan kulit bermata banyak. Daging buahnya…

Who Am I?

These questions are timeless, and have arguably been the driving force behind every cultural renaissance throughout the evolution of Homo sapiens. Scientists are ostensibly the leaders in this quest…