# Deep learning examples

These examples illustrate the basic usage of Concrete ML to build various types of neural networks. They use simple data-sets, focusing on the syntax and usage of Concrete ML. For examples showing how to train high-accuracy models on more complex data-sets, see the [Demos and Tutorials](/concrete-ml/tutorials/showcase.md) section.

## FHE constraints considerations

The examples listed here make use of [simulation](/concrete-ml/explanations/compilation.md#fhe-simulation) to perform evaluation over large test sets. Since FHE execution can be slow, only a few FHE executions can be performed. The [correctness guarantees](/concrete-ml/get-started/concepts.md#cryptography-concepts) of Concrete ML ensure that accuracy measured with simulation is the same as that which will be obtained during FHE execution.

Some examples constrain accumulators to 7-8 bits, which can be sufficient for simple data-sets. Up to 16-bit accumulators can be used, but this introduces a slowdown of 4-5x compared to 8-bit accumulators.

## List of Examples

### 1. Step-by-step guide to building a custom NN

* [Quantization aware training example](https://github.com/zama-ai/concrete-ml/blob/release/1.9.x/docs/advanced_examples/QuantizationAwareTraining.ipynb)

This shows how to use Quantization Aware Training and pruning when starting out from a classical PyTorch network. This example uses a simple data-set and a small NN, which achieves good accuracy with low accumulator size.

### 2. Custom convolutional NN on the [Digits](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html) data-set

* [Convolutional Neural Network](https://github.com/zama-ai/concrete-ml/blob/release/1.9.x/docs/advanced_examples/ConvolutionalNeuralNetwork.ipynb)

Following the [Step-by-step guide](/concrete-ml/deep-learning/fhe_friendly_models.md), this notebook implements a Quantization Aware Training convolutional neural network on the MNIST data-set. It uses 3-bit weights and activations, giving a 7-bit accumulator.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zama.org/concrete-ml/tutorials/dl_examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
