Category Archives: bitcoin

Deep Learning with the Movidius Neural Compute Stick


Deep Learning is a breakthrough in Artificial Intelligence. With its root from neural network, modern computing hardware advancement enabled new possibilities by sophisticated integrated circuits technology.

A branch of this exciting area in AI is machine learning. The leading development frameworks include TensorFlow and Caffe. Pattern recognition is a practical application of machine learning where photos or videos are analysed by machine to produce usable output as if a human did the analysis. GPU has been a favorite choice for its specialized architecture, delivering its supreme processing power not only in graphics processing but also popular among the neural network community. Covered in a previous installment is how to deploy an Amazon Web Services GPU instance to analyse real time traffic camera images using Caffe.

To bring this kind of machine learning power to IoT, Intel shrank and packaged a specialized Vision Processing Unit into the form factor of a USB thumb drive in the Movidius™ Neural Compute Stick.

It sports an ultra low power Vision Processing Unit (VPU) inside an aluminium casing, weights only 30g (without the cap). Supported on the Raspberry Pi 3 model B makes it a very attractive add-on for development projects involving AI application on this platform.IMAG1435

In the form factor of an USB thumb drive, the specialized VPU geared for machine learning in the Movidius performs as an AI accelerator for the host computer.IMAG1439

To put this neural compute stick into action, an SDK available from git download provided by Movidius is required. Although this SDK runs on Ubuntu, Windows users with VirtualBox can easily install the SDK with an Ubuntu 16.04 VM.

While the SDK comes with many examples, and the setup is a walk in the park, running these examples is not so straight forward, especially on a VM. There are points to note from making this stick available in the VM including USB 3 and filters setting in VirtualBox, to the actual execution of the provided sample scripts. Some examples required two sticks to run. Developers should be comfortable with Python, unix make / git commands, as well as installing plugins in Ubuntu.

The results from the examples in the SDK alone are quite convincing, considering the form factor of the stick and its electrical power consumption. This neural computing stick “kept its cool” literally throughout the test drive, unlike the FPGA stick I occasionally use for bitcoins mining which turn really hot.


Bitcoin inflation

Bitcoins are created through reward for successfully mining a block. The current reward as of writing is 12.5 BTC per block.

Referring to the bitcoin history, the current bitcoin in circulation is around 16,378,375, and a year ago it was 15,628,475. So there is 749,900 bitcoins being mined in between.

The rate of a successful mining is around 10 minutes. Assuming this, in one year there should be 24 * 60 / 10 * 12.5 * 365 bitcoins created. That is 657,000 and this theoretical value doesn’t quite add up with the history as this only amounts to 87.6% to the historic value. Close, but more than 10% than expected.

It turns out, in fact, there is a mechanism built-in to the bitcoin to halve the reward as a form of inflation. A month from now will mark the anniversary for the last Bitcoin reward halving from 25 BTC to 12.5 BTC. This change is by design and happened twice as expected in the past, from 50 to 25, to 12.5 as of time of writing.

The first block receiving 12.5 BTC is 420,000 on 2016-07-09, according to the original constant set in stone by the creator of Bitcoin:

Consensus.nSubsidyHalvingInterval = 210000;

Therefore during the period mentioned above where 749,900 are mined there are times when the reward was 25 and some other 12.5.

A rough calculation shown the current reward, which is 12.5 BTC per block, applies to 334 days during that 365-day period. Revising the calculation of the theoretical value resulted in 712,800 bitcoins. Taking into account this fact the estimation improved from 88% to 95% of historical values.

What does endianness have to do with Bitcoins

The order of the byte appears is called the endianness in computer technology. This term stem from processor architecture design, for example, x86 and the classic 6502 is little endian, while S/360 and SPARC are big endian. ARM processors like the one powering the Beagleboard SBC I am happy with from Yubikey to the R statistics package can be configured to run either.

At the end of the day, programs are compiled and linked to instruction sets for the hardware processor to execute. But that is not the end of the story for software developers. Apart from the hardware instruction sets there are also endianness in file. Any developers having involved in any form of low level file processing, in classic or modern programming languages alike, should be very familiar with this.

Take the bitcoin file as en example, the hex dump below is the genesis bitcoin with the timestamp field highlighted in yellow.


On file it reads 29AB5F49, but for the sake of endianness, this value should be interpreted as 495FAB29 in hexadecimal, and the corresponding decimal value is 1231006505. Converting this decimal value timestamp into human readable date:

It is quite trivial to convert from one to another through programming languages and a classic C example as simple as the below macro will do the job.


In Python:


Using TI Nspire to explore mathematics behind blockchain technology

The TI Nspire is a great tool for exploring mathematics through its calculation and graphing capability. One of the emerging technologies that is based on mathematics is blockchain. It gained popularity through bitcoin that caused much debate and controversy in the field of banking, economics and finance. Until recently more and more established research and technology firms started to look at it seriously and its underlying core technology, blockchain, is gaining momentum for being adopted by traditional financial institutions.

In a previous installment, the property of the Elliptic Curve is explored using TI Nspire. As shown in the dynamic graph below, the curve exhibit several properties that form the two basic operations of asymmetric encryption – point addition and point doubling – for public and private key pair generation.


Using a=0, and b=7 as in Bitcoin, the two properties are basically illustrated in the following graphs.

Point Addition

Point Doubling

However, in reality, the Elliptic Curve Digital Signature Algorithm (ECDSA) algorithm to generate public and private key relied also on another mathematical concept known as the finite field. This is basically a limit imposed on the numbers that are available for use in the calculation, and in this case, positive integers from a modulo calculation. The prime modulo for Bitcoin (as in secp256k1) is set to  2256 – 232 – 29 – 28 – 27 – 26 – 24 – 1. Having this in place, the graph will not look like the above but some scattered points on a fixed region, and overflows will wrap around. However, the symmetry will still be preserved and recognized visually on graph.

With this mathematical backed technology as the foundation, blockchain can provides open ledger for secure transaction service.