Created at 9am, Apr 24
benjaminArtificial Intelligence
0
the MLBook
W7WUD_6O3_2AYvZM5a_NuywlhvsF9yvq_Ovjru7tt_M
File Type
PDF
Entry Count
393
Embed. Model
text_embedding_3_small
Index Type
hnsw

THEHUNDRED-PAGE MACHINELEARNING BOOK by Andriy Burkov

A convolutional neural network (CNN) is a special kind of FFNN that signicantly reduces the number of parameters in a deep neural network with many units without losing too much in the quality of the model. CNNs have found applications in image and text processing where they beat many previously established benchmarks. Because CNNs were invented with image processing in mind, I explain them on the image classication example. You may have noticed that in images, pixels that are close to one another usually represent the same type of information: sky, water, leaves, fur, bricks, and so on. The exception from the rule are the edges: the parts of an image where two different objects touch one another.
id: b0cb83f5910c4bbaad5c91e56f3ee1c7 - page: 85
If we can train the neural network to recognize regions of the same information as well as the edges, this knowledge would allow the neural network to predict the object represented in the image. For example, if the neural network detected multiple skin regions and edges that look like parts of an oval with skin-like tone on the inside and bluish tone on the outside, then it is likely that its a face on the sky background. If our goal is to detect people on pictures, the neural network will most likely succeed in predicting a person in this picture.
id: f74454c92ef30432e8eb1ecf1497cb2f - page: 85
Having in mind that the most important information in the image is local, we can split the image into square patches using a moving window approach4. We can then train multiple smaller regression models at once, each small regression model receiving a square patch as input. The goal of each small regression model is to learn to detect a specic kind of pattern in the input patch. For example, one small regression model will learn to detect the sky; another one will detect the grass, the third one will detect edges of a building, and so on.
id: 9b50ceb94024b5e83f6c12f839b41ff8 - page: 85
In CNNs, a small regression model looks like the one in Figure 6.1, but it only has the layer 1 and doesnt have layers 2 and 3. To detect some pattern, a small regression model has to learn the parameters of a matrix F (for lter) of size p p, where p is the size of a patch. Lets assume, for simplicity, that the input image is black and white, with 1 representing black and 0 representing white pixels. Assume also that our patches are 3 by 3 pixels (p = 3). Some patch could then look like the following matrix P (for patch): P = 0 1 0 1 1 1 0 1 0 . 3Each pixel of an image is a feature. If our image is 100 by 100 pixels, then there are 10,000 features. 4Consider this as if you looked at a dollar bill in a microscope. To see the whole bill you have to gradually move your bill from left to right and from top to bottom. At each moment in time, you see only a part of the bill of xed dimensions. This approach is called moving window. 66
id: cc0f8edf0c5c17e5630b5c44dd21da4d - page: 85
How to Retrieve?
# Search

curl -X POST "https://search.dria.co/hnsw/search" \
-H "x-api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"rerank": true, "top_n": 10, "contract_id": "W7WUD_6O3_2AYvZM5a_NuywlhvsF9yvq_Ovjru7tt_M", "query": "What is alexanDRIA library?"}'
        
# Query

curl -X POST "https://search.dria.co/hnsw/query" \
-H "x-api-key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"vector": [0.123, 0.5236], "top_n": 10, "contract_id": "W7WUD_6O3_2AYvZM5a_NuywlhvsF9yvq_Ovjru7tt_M", "level": 2}'