Dokumentation (english)
AI DictionaryPart 3: Training

AI Classification

How AI models classify data using filters

Imagine a tunnel with several filters inside it:

  1. one filter is cupboard with some holes in it
  2. one filter is a pile of pillows where you could squeeze through

Small animals like a cat can pass through all filters. Large animals like a dog cannot.

If something comes out of the tunnel, it must be small (cat → 1) If nothing comes out, it was too large (dog → 0)

This is AI classification.

The architecture defines what filters are used.

Example: Classification in Code

Here is how the tunnel classifier works in code:

import torch import torch.nn as nn class TunnelClassifier(nn.Module): def __init__(self): super().__init__() # Each layer acts like a filter in the tunnel self.filters = nn.Sequential( nn.Linear(10, 8), # first filter nn.ReLU(), nn.Linear(8, 4), # second filter (stricter) nn.ReLU(), nn.Linear(4, 1) # final decision ) def forward(self, x): x = self.filters(x) return torch.sigmoid(x) # output between 0 and 1

How Data Flows Through

Input data → Filter 1 → Filter 2 → Decision
  • Input (x): animal
  • Each Linear layer: a filter in the tunnel
  • ReLU: blocks values that don't fit
  • Final output:
    • close to 1 → cat
    • close to 0 → dog

If the data can pass all filters → it reaches the end → cat (1) If it fails → signal collapses → dog (0)

Example Inference

model = TunnelClassifier() # Example animal features cat_like = torch.rand(1, 10) # fits filters dog_like = torch.rand(1, 10) * 0.1 # likely blocked print("Cat prediction:", model(cat_like).item()) print("Dog prediction:", model(dog_like).item())

In the code example above, torch.rand(1, 10) represents 10 features of an animal.


Command Palette

Search for a command to run...

Schnellzugriffe
STRG + KSuche
STRG + DNachtmodus / Tagmodus
STRG + LSprache ändern

Software-Details
Kompiliert vor 15 Tagen
Release: v4.0.0-production
Buildnummer: master@6fbd7b5
Historie: 13 Items