• Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    C++
  • Created over 7 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

tiny-cnn: A header only, dependency-free deep learning framework in C++11

Xilinx changes from original tiny-cnn:

  • added batchnorm layer (currently feedforward only, no training)
  • support for offloaded layer
  • interleave layer
  • binarized layers
Linux/Mac OS Windows
Build Status Build status

tiny-cnn is a C++11 implementation of deep learning. It is suitable for deep learning on limited computational resource, embedded systems and IoT devices.

see Wiki Pages for more info.

Features

  • fast, without GPU
    • with TBB threading and SSE/AVX vectorization
    • 98.8% accuracy on MNIST in 13 minutes training (@Core i7-3520M)
  • header only
    • Just include tiny_cnn.h and write your model in c++. There is nothing to install.
  • small dependency & simple implementation
  • can import caffe's model

Comparison with other libraries

tiny-cnn caffe Theano TensorFlow
Prerequisites Nothing(Optional:TBB,OpenMP) BLAS,Boost,protobuf,glog,gflags,hdf5, (Optional:CUDA,OpenCV,lmdb,leveldb etc) Numpy,Scipy,BLAS,(optional:nose,Sphinx,CUDA etc) numpy,six,protobuf,(optional:CUDA,Bazel)
Modeling By C++ code Config File Python Code Python Code
GPU Support No Yes Yes Yes
Installing Unnecessary Necessary Necessary Necessary
Windows Support Yes No* Yes No*
Pre-Trained Model Yes(via caffe-converter) Yes No* No*

*unofficial version is available

Supported networks

layer-types

  • fully-connected layer
  • convolutional layer
  • average pooling layer
  • max-pooling layer
  • contrast normalization layer
  • dropout layer
  • linear operation layer

activation functions

  • tanh
  • sigmoid
  • softmax
  • rectified linear(relu)
  • leaky relu
  • identity
  • exponential linear units(elu)

loss functions

  • cross-entropy
  • mean-squared-error

optimization algorithm

  • stochastic gradient descent (with/without L2 normalization and momentum)
  • stochastic gradient levenberg marquardt
  • adagrad
  • rmsprop
  • adam

Dependencies

Minimum requirements

Nothing.All you need is a C++11 compiler.

Requirements to build sample/test programs

OpenCV

Build

tiny-cnn is header-ony, so there's nothing to build. If you want to execute sample program or unit tests, you need to install cmake and type the following commands:

cmake .

Then open .sln file in visual studio and build(on windows/msvc), or type make command(on linux/mac/windows-mingw).

Some cmake options are available:

options description default additional requirements to use
USE_TBB Use Intel TBB for parallelization OFF* Intel TBB
USE_OMP Use OpenMP for parallelization OFF* OpenMP Compiler
USE_SSE Use Intel SSE instruction set ON Intel CPU which supports SSE
USE_AVX Use Intel AVX instruction set ON Intel CPU which supports AVX
BUILD_TESTS Build unist tests OFF -**
BUILD_EXAMPLES Build example projects ON -

*tiny-cnn use c++11 standard library for parallelization by default **to build tests, type git submodule update --init before build

For example, type the following commands if you want to use intel TBB and build tests:

cmake -DUSE_TBB=ON -DBUILD_EXAMPLES=ON .

Customize configurations

You can edit include/config.h to customize default behavior.

Examples

construct convolutional neural networks

#include "tiny_cnn/tiny_cnn.h"
using namespace tiny_cnn;
using namespace tiny_cnn::activation;

void construct_cnn() {
    using namespace tiny_cnn;

    // specify loss-function and optimization-algorithm
    network<mse, adagrad> net;
    //network<cross_entropy, RMSprop> net;

    // add layers
    net << convolutional_layer<tan_h>(32, 32, 5, 1, 6) // 32x32in, conv5x5, 1-6 f-maps
        << average_pooling_layer<tan_h>(28, 28, 6, 2) // 28x28in, 6 f-maps, pool2x2
        << fully_connected_layer<tan_h>(14 * 14 * 6, 120)
        << fully_connected_layer<identity>(120, 10);

    assert(net.in_dim() == 32 * 32);
    assert(net.out_dim() == 10);
    
    // load MNIST dataset
    std::vector<label_t> train_labels;
    std::vector<vec_t> train_images;
    
    parse_mnist_labels("train-labels.idx1-ubyte", &train_labels);
    parse_mnist_images("train-images.idx3-ubyte", &train_images);
    
    // train (50-epoch, 30-minibatch)
    net.train(train_images, train_labels, 30, 50);
    
    // save
    std::ofstream ofs("weights");
    ofs << net;
    
    // load
    // std::ifstream ifs("weights");
    // ifs >> net;
}

construct multi-layer perceptron(mlp)

#include "tiny_cnn/tiny_cnn.h"
using namespace tiny_cnn;
using namespace tiny_cnn::activation;

void construct_mlp() {
    network<mse, gradient_descent> net;

    net << fully_connected_layer<sigmoid>(32 * 32, 300)
        << fully_connected_layer<identity>(300, 10);

    assert(net.in_dim() == 32 * 32);
    assert(net.out_dim() == 10);
}

another way to construct mlp

#include "tiny_cnn/tiny_cnn.h"
using namespace tiny_cnn;
using namespace tiny_cnn::activation;

void construct_mlp() {
    auto mynet = make_mlp<mse, gradient_descent, tan_h>({ 32 * 32, 300, 10 });

    assert(mynet.in_dim() == 32 * 32);
    assert(mynet.out_dim() == 10);
}

more sample, read examples/main.cpp or MNIST example page.

References

[1] Y. Bengio, Practical Recommendations for Gradient-Based Training of Deep Architectures. arXiv:1206.5533v2, 2012

[2] Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner, Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86, 2278-2324.

other useful reference lists:

License

The BSD 3-Clause License

Mailing list

google group for questions and discussions:

https://groups.google.com/forum/#!forum/tiny-cnn-users

More Repositories

1

PYNQ

Python Productivity for ZYNQ
Jupyter Notebook
1,975
star
2

Vitis-AI

Vitis AI is Xilinx’s development stack for AI inference on Xilinx hardware platforms, including both edge devices and Alveo cards.
Python
1,475
star
3

linux-xlnx

The official Linux kernel from Xilinx
C
1,205
star
4

brevitas

Brevitas: neural network quantization in PyTorch
Python
1,158
star
5

Vitis-Tutorials

Vitis In-Depth Tutorials
C
891
star
6

Vitis_Libraries

Vitis Libraries
C++
853
star
7

embeddedsw

Xilinx Embedded Software (embeddedsw) Development
HTML
766
star
8

finn

Dataflow compiler for QNN inference on FPGAs
Python
715
star
9

BNN-PYNQ

Quantized Neural Networks (QNNs) on PYNQ
Jupyter Notebook
661
star
10

XRT

Run Time for AIE and FPGA based platforms
C++
553
star
11

u-boot-xlnx

The official Xilinx u-boot repository
C
531
star
12

Vitis_Accel_Examples

Vitis_Accel_Examples
Makefile
503
star
13

Vitis-HLS-Introductory-Examples

C++
420
star
14

dma_ip_drivers

Xilinx QDMA IP Drivers
C
400
star
15

HLS

Vitis HLS LLVM source code and examples
378
star
16

Vitis-AI-Tutorials

362
star
17

PYNQ_Workshop

Jupyter Notebook
354
star
18

SDAccel_Examples

SDAccel Examples
C++
350
star
19

ml-suite

Getting Started with Xilinx ML Suite
Jupyter Notebook
334
star
20

CHaiDNN

HLS based Deep Neural Network Accelerator Library for Xilinx Ultrascale+ MPSoCs
C++
322
star
21

xfopencv

C++
313
star
22

XilinxTclStore

Xilinx Tcl Store
Tcl
310
star
23

mlir-aie

An MLIR-based toolchain for AMD AI Engine-enabled devices.
MLIR
300
star
24

XilinxBoardStore

Python
251
star
25

RapidWright

Build Customized FPGA Implementations for Vivado
Java
248
star
26

QNN-MO-PYNQ

Jupyter Notebook
236
star
27

libsystemctlm-soc

SystemC/TLM-2.0 Co-simulation framework
Verilog
210
star
28

qemu

Xilinx's fork of Quick EMUlator (QEMU) with improved support and modelling for the Xilinx platforms.
C
200
star
29

DPU-PYNQ

DPU on PYNQ
Tcl
198
star
30

device-tree-xlnx

Linux device tree generator for the Xilinx SDK (Vivado > 2014.1)
Tcl
181
star
31

finn-examples

Dataflow QNN inference accelerator examples on FPGAs
Python
174
star
32

PYNQ-ComputerVision

Computer Vision Overlays on Pynq
Jupyter Notebook
173
star
33

XilinxVirtualCable

Xilinx Virtual Cable (XVC) is a TCP/IP-based protocol that acts like a JTAG cable and provides a means to access and debug your FPGA or SoC design without using a physical cable.
C
172
star
34

finn-hlslib

Vitis HLS Library for FINN
C++
172
star
35

graffitist

Graph Transforms to Quantize and Retrain Deep Neural Nets in TensorFlow
Python
169
star
36

open-nic

AMD OpenNIC Project Overview
Shell
166
star
37

SDSoC-Tutorials

SDSoCβ„’ (Software-Defined System-On-Chip) Environment Tutorials
C++
142
star
38

FPGA_as_a_Service

Go
136
star
39

xup_vitis_network_example

VNx: Vitis Network Examples
Jupyter Notebook
133
star
40

meta-xilinx

Collection of Yocto Project layers to enable AMD Xilinx products
C
123
star
41

systemctlm-cosim-demo

QEMU libsystemctlm-soc co-simulation demos.
C++
114
star
42

Vitis-In-Depth-Tutorial

C++
113
star
43

Vitis_Embedded_Platform_Source

Tcl
105
star
44

llvm-aie

Fork of LLVM to support AMD AIEngine processors
LLVM
104
star
45

SDAccel-Tutorials

SDAccel Development Environment Tutorials
C++
101
star
46

nanotube

LLVM
101
star
47

Embedded-Design-Tutorials

100
star
48

RecoNIC

RecoNIC is a software/hardware shell used to enable network-attached processing within an RDMA-featured SmartNIC for scale-out computing.
SystemVerilog
94
star
49

RFNoC-HLS-NeuralNet

CMake
92
star
50

PYNQ-DL

Xilinx Deep Learning IP
VHDL
91
star
51

Kria-PYNQ

PYNQ support and examples for Kria SOMs
Jupyter Notebook
90
star
52

PYNQ-HelloWorld

This repository contains a "Hello World" introduction application to the Xilinx PYNQ framework.
Jupyter Notebook
90
star
53

LSTM-PYNQ

C++
86
star
54

kria-vitis-platforms

Kria Vitis platforms and overlays
SystemVerilog
86
star
55

meta-petalinux

meta-petalinux distro layer supporting Xilinx Tools
BitBake
84
star
56

Vivado-Design-Tutorials

Tcl
83
star
57

SDSoC_Examples

C++
82
star
58

ACCL

Alveo Collective Communication Library: MPI-like communication operations for Xilinx Alveo accelerators
C++
81
star
59

logicnets

Python
80
star
60

IIoT-EDDP

The repository contains the design database and documentation for Electric Drives Demonstration Platform
VHDL
79
star
61

mlir-air

C++
77
star
62

AI-Model-Zoo

75
star
63

Applications

C
71
star
64

open-nic-shell

AMD OpenNIC Shell includes the HDL source files
SystemVerilog
70
star
65

XilinxUnisimLibrary

Xilinx Unisim Library in Verilog
Verilog
66
star
66

PYNQ_Composable_Pipeline

PYNQ Composabe Overlays
Tcl
64
star
67

merlin-compiler

C++
57
star
68

PYNQ_RFSOC_Workshop

Open-sourcing the PYNQ & RFSoC workshop materials
Jupyter Notebook
56
star
69

gemx

Matrix Operation Library for FPGA https://xilinx.github.io/gemx/
C++
56
star
70

xup_high_level_synthesis_design_flow

AMD University Program HLS tutorial
Jupyter Notebook
54
star
71

meta-xilinx-tools

Yocto Project layer enables AMD Xilinx tools related metadata for MicroBlaze, Zynq, ZynqMP and Versal devices.
BitBake
54
star
72

RFSoC-PYNQ

Python productivity for RFSoC platforms
Jupyter Notebook
52
star
73

Alveo-PYNQ

Introductory examples for using PYNQ with Alveo
Jupyter Notebook
48
star
74

ResNet50-PYNQ

Quantized ResNet50 Dataflow Acceleration on Alveo, with PYNQ
C++
48
star
75

xup_compute_acceleration

Hands-on experience using the Vitis unified software platform with Xilinx FPGA hardware
C++
46
star
76

Vitis_Model_Composer

Vitis Model Composer Examples and Tutorials
C++
46
star
77

KRS

The Kria Robotics Stack (KRS) is a ROS 2 superset for industry, an integrated set of robot libraries and utilities to accelerate the development, maintenance and commercialization of industrial-grade robotic solutions while using adaptive computing.
HTML
46
star
78

Vitis-AWS-F1-Developer-Labs

C++
45
star
79

PYNQ_Bootcamp

PYNQ Bootcamp 2019-2022 teaching materials.
Jupyter Notebook
44
star
80

PYNQ-Networking

Networking Overlay on PYNQ
Tcl
44
star
81

HLS_packet_processing

C++
43
star
82

blockchainacceleration

Tcl
43
star
83

Get_Moving_With_Alveo

For publishing the source for UG1352 "Get Moving with Alveo"
C++
42
star
84

DSRL

42
star
85

pcie-model

PCI Express controller model
C
41
star
86

XilinxCEDStore

This store contains Configurable Example Designs.
Tcl
41
star
87

inference-server

C++
41
star
88

HLS_arbitrary_Precision_Types

C++
40
star
89

Xilinx_Kria_KV260_Workshop

40
star
90

vcu-ctrl-sw

C
38
star
91

VVAS

Vitis Video Analytics SDK
C
38
star
92

chipscopy

ChipScoPy (ChipScope Python API) is an open source Python API to the various ChipScope services provided by the TCF-based (Target Communication Framework) ChipScope Server (cs_server).
Jupyter Notebook
38
star
93

pyxir

Python
36
star
94

xup_aie_training

Hands-on experience programming AI Engines using Vitis Unified Software Platform
Jupyter Notebook
36
star
95

DSP-PYNQ

A PYNQ overlay demonstrating Pythonic DSP running on Zynq UltraScale+
Tcl
36
star
96

hdmi-modules

Xilinx Soft-IP HDMI Rx/Tx core Linux drivers
C
35
star
97

pytorch-ocr

Python
35
star
98

open-nic-driver

AMD OpenNIC driver includes the Linux kernel driver
C
33
star
99

bootgen

bootgen source code
C++
33
star
100

qemu-devicetrees

Device trees used by QEMU to describe the hardware
Makefile
32
star