Saturday, January 14, 2017

Tiny-DNN: Development "as fast as possible" guide

I'm writing this as a simple instruction/refernce to get started using Tiny-DNN to build stuff as fast as possible.

I'm doing this on Ubuntu on Windows 10, Any recent Ubuntu system should have similar if not the same methods of starting.

if you don't have cmake and the gnu c++ compiles:
sudo apt-get install build-essential
sudo apt-get install cmake

(Optional)
if you want to build tiny-dnn with Intel Threading Building Blocks:

sudo apt-get install libtbb-dev

1) clone repo:

git clone https://github.com/tiny-dnn/tiny-dnn

2) Build
cd tiny-dnn

the most simple option is
cmake . 


If you're building with TBB then:
cmake -DUSE_TBB=ON

the build should end with no errors.


3) Building a program:

create a simple program 

for my system, I have to add "#include " to get the program to compile or it will start emitting build errors such as:




I'm going to use one of the sample code in the documentation that constructs a MLP.

// filename: sample.cpp
#include 
#include "tiny_dnn/tiny_dnn.h"
using namespace tiny_dnn;
using namespace tiny_dnn::activation;
using namespace tiny_dnn::layers;

void construct_mlp() {
    network net;

    net << fc(32 * 32, 300)
        << fc(300, 10);

    assert(net.in_data_size() == 32 * 32);
    assert(net.out_data_size() == 10);
}
int main()
{
        construct_mlp();
}

once done compile it (/mnt/e/linuxbuild/tiny-dnn being the directory that was cloned from github and built in #1 and #2)

g++ -pthread -std=c++11 -I /mnt/e/linuxbuild/tiny-dnn sample.cpp

The compiler should build a.out binary successfully.