<commit_before># NanoCV

This small (nano) library is used as a sandbox for training and testing models, such as neural networks and convolution networks, on various image classification and object detection problems. 

## Concepts

The library is built around several key concepts mapped to C++ object interfaces. Each object instantation is registered with an *ID* and thus it can be selected 
from command line arguments. 

### Task

A task describes a classification or regression problem consisting of separate training and test image patches with associated target outputs if any. 
This concept maps known machine learning and computer vision benchmarks to a common interface. Well-known datasets that are supported: MNIST, CIFAR-10, CIFAR-100, CMU-FACES, STL-10, NORB.

### Model

A model predicts the correct output for a given image patch. The output can be a label (if a classification task) or a score (if a regression task). Implemented instances:

* **forward network** - a collection of feed-forward connected layers: the output of a layer is the input of the next. Implemented layers: *convolution*, 
*activation* (hyperbolic tangent, unit, signed normalization), *linear* and *pooling* (maximum, maximum absolute).

### Loss 

A loss function assigns a scalar score to the prediction of a model by comparing it with the ground truth target (if provided). 
The lower the score, the better the prediction. Implemented instances: class-NLL, logistic and square.

### Trainer

A trainer otimizes the parameters of a *given model* to produce the correct outputs for a *given task* using the cumulated values of a *given loss* over 
the training samples as a numerical optimization criteria. Implemented instances:

* **batch** - a single iteration typically consists of a pass through all training samples. There are several options available: *L-BFGS*, conjugate gradient 
descent (*CGD*) and gradient descent (*GD*).

* **minibatch** - a single iteration typically consists of computing the gradient over a small subset (minibatch) of the training samples and then performing a line-search over the same minibatch
as in the gradient descent algorithm.

* **stochastic** - an iteration consists of picking a random sample to update the descent direction. There are several options available: *SGD* (stochastic gradient descent) and *ASGD* (average stochastic gradient descent).
The training is split in two phases: the tuning phase estimates the optimum learning rate parameters on a small subset of samples, while the optimization phase uses the optimum parameters to train the model.

## Usage

### Compilation

To compile (and install) CMake, a C++11 compiler, Boost, Eigen, libTIFF, libPNG and libJPEG are required. The library is tested so far only on ArchLinux x64, but the 
code is written to be cross-platform.

The easiest way of compiling is to run the `build.sh` bash script. The test programs and utilities will be found in the created `build` directory.

### Examples

The library provides various command line programs and utilities. Each program displays its possible arguments with short explanations by running it with `--help`.

* **ncv_info** - prints all registered objects with their IDs and short descriptions.

* **ncv_info_task** - loads a task and prints its detailed description.

* **ncv_trainer** - train a model on a given task.

* **ncv_tester** - test a model on a given task.

The `experiments.sh` contains examples on how to train various models on different tasks.




 
<commit_msg>updated & more compact README<commit_after># NanoCV

This small (nano) library is used as a sandbox for training and testing models, such as neural networks and convolution networks, on various image classification and object detection problems. 

## Concepts

The library is built around several key concepts mapped to C++ object interfaces. Each object instantation is registered with an *ID* and thus it can be selected 
from command line arguments. 

### Task

A task describes a classification or regression problem consisting of separate training and test image patches with associated target outputs if any. 
This concept maps known machine learning and computer vision benchmarks to a common interface. Well-known datasets that are supported: *MNIST*, *CIFAR-10*, *CIFAR-100*, *CMU-FACES*, *STL-10*, *NORB*.

### Model

A model predicts the correct output for a given image patch. The output can be a label (if a classification task) or a score (if a regression task). Implemented instances:

* **forward network** - a collection of feed-forward connected layers: the output of a layer is the input of the next. Implemented layers: *convolution*, 
*activation* (hyperbolic tangent, unit, signed normalization), *linear* and *pooling* (maximum, maximum absolute).

### Loss 

A loss function assigns a scalar score to the prediction of a model by comparing it with the ground truth target (if provided). 
The lower the score, the better the prediction. Implemented instances: *class-NLL*, *logistic* and *square*.

### Trainer

A trainer otimizes the parameters of a *given model* to produce the correct outputs for a *given task* using the cumulated values of a *given loss* over the training samples as a numerical optimization criteria. Implemented instances: *batch* (using *L-BFGS*, conjugate gradient descent (*CGD*) or gradient descent (*GD*)), *minibatch* and *stochastic*.

## Usage

### Compilation

To compile (and install) CMake, a C++11 compiler, Boost, Eigen, libTIFF, libPNG and libJPEG are required. The library is tested so far only on ArchLinux x64, but the 
code is written to be cross-platform.

The easiest way of compiling is to run the `build.sh` bash script. The test programs and utilities will be found in the created `build` directory.

### Examples

The library provides various command line programs and utilities. Each program displays its possible arguments with short explanations by running it with `--help`.

* **ncv_info** - prints all registered objects with their IDs and short descriptions.

* **ncv_info_task** - loads a task and prints its detailed description.

* **ncv_trainer** - train a model on a given task.

* **ncv_tester** - test a model on a given task.

The `experiments.sh` contains examples on how to train various models on different tasks.




 

{'fraction_non_alphanumeric': 0.0653305980747988, 'fraction_numerical': 0.003471674293829888, 'mean_word_length': 4.593998234774934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3762166', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1525, 'n_words': 913}