A quick introduction into using TFCNN a C library for Artificial Neural Networks

// let’s create an instance of our network.
network net;
// and initialise the network ..
const uint number_of_inputs = 1;
const uint number_of_layers = 2;
const uint number_of_neurons_per_layer = 256;
createNetwork(&net, WEIGHT_INIT_UNIFORM_LECUN, number_of_inputs, number_of_layers, number_of_neurons_per_layer);
// maybe also you would like to change the default configured optimiser and activator
setOptimiser(&net, OPTIM_MOMENTUM);
setActivator(&net, TANH);
float processNetwork(network* net, const float* inputs, const learn_type learn)
  • To train towards your target (1) you will use LEARN_MAX which will minimize the gradient descent, sloping down to a local minimum.
  • To train away from your target (0) you will use LEARN_MIN which will maximize the gradient descent, sloping up away from a local minimum.
void setTargetMax(&net, 1); // LEARN_MAX
void setTargetMin(&net, 0); // LEARN_MIN
const float positive_words[10] = {0.1, 0.01, 0.2, 0.13, 0.142, 0.056, 0.21, 0.023, 0.31, 0.312};
const float negative_words[10] = {0.9, 0.91, 0.8, 0.87, 0.73, 0.934, 0.67, 0.074, 0.703, 0.883};
for(uint i = 0; i < 10; ++i)
// learn to output 1 for positive words
processNetwork(&net, &positive_words[i], LEARN_MAX);
// learn to output 0 for negative words
processNetwork(&net, &negative_words[i], LEARN_MIN);
const float input = 0.9;
const float is_positive = processNetwork(&net, &input, NO_LEARN);
if(is_positive > 0.6)
printf(“Looks like the input was positive +\n”);
printf(“Looks like the input was negative -\n”);




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building an Embedded System, Part 2: The Hardware

Pngtree Love Your Valentines Day Adver

Zunami Protocol Ambasador programm

How Microsoft’s Azure Plans to Beat Amazon Web Services

Postmortem project is based on details of web_stack_debbuging_3 and how we solve the error that we…

Can’t “Make-Up” My Mind And Figure Out What I’m Doing Wrong!

BBD achieve the Well-Architected Partner status

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

Primer on Pytorch’s Dataset class

How is “physics informed” neural network any different than “non-physics informed” neural network?

ML Model Optimization for low compute environments

PyTorch: Tools that helps developers to design and install AI