skills/AI/AI-Deep-Learning/SKILL.md
Help users understand and implement deep learning concepts including neural networks, CNNs, RNNs, LLMs, and diffusion models. Use this skill whenever the user asks about deep learning architectures, wants to build neural networks in PyTorch, needs help with training loops, or wants to understand concepts like backpropagation, activation functions, attention mechanisms, or generative models. Make sure to use this skill for any deep learning related questions, code reviews, architecture design, or implementation help.
npx skillsauth add abelrguezr/hacktricks-skills deep-learning-helperInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A comprehensive guide to deep learning concepts and PyTorch implementation.
Neural networks are the foundation of deep learning. They consist of interconnected neurons organized in layers:
Each neuron computes: z = w * x + b then applies an activation function.
Activation functions introduce non-linearity, enabling networks to learn complex patterns:
| Function | Range | Use Case | |----------|-------|----------| | Sigmoid | 0 to 1 | Binary classification output | | ReLU | 0 to ∞ | Hidden layers (most common) | | Tanh | -1 to 1 | Hidden layers | | Softmax | 0 to 1 (sums to 1) | Multi-class classification output |
Key insight: Without activation functions, a neural network is just a linear transformation regardless of depth.
The training algorithm that adjusts weights to minimize loss:
CNNs excel at processing grid-like data (images) by learning spatial hierarchies of features.
Convolutional Layers: Apply learnable filters to extract features
Pooling Layers: Downsample feature maps
Fully Connected Layers: Final classification
# Standard pattern: Conv → ReLU → Conv → ReLU → Pool
# Repeat, then flatten → FC → Output
For a convolutional layer:
Parameters = (kernel_height × kernel_width × in_channels + 1) × out_channels
The +1 is for the bias term per output channel.
For a fully connected layer:
Parameters = (input_features + 1) × output_features
See scripts/cnn_template.py for a complete CNN implementation.
Key considerations:
RNNs process sequential data by maintaining a hidden state across time steps.
Standard RNNs struggle with long-range dependencies due to vanishing gradients. LSTMs and GRUs solve this with gating mechanisms:
LSTM (Long Short-Term Memory):
GRU (Gated Recurrent Unit):
LLMs use transformer architecture for natural language tasks.
Self-Attention: Weighs importance of different words in context
Multi-Head Attention: Multiple attention mechanisms in parallel
Positional Encoding: Adds position information
Generative models that create data by reversing a noise-adding process.
Forward Process: Gradually add noise to data
Reverse Process: Learn to denoise
Image Generation Pipeline:
| Parameter | Typical Range | Notes | |-----------|---------------|-------| | Learning Rate | 1e-4 to 1e-3 | Adam optimizer | | Batch Size | 32 to 256 | Depends on GPU memory | | Epochs | 5 to 100 | Monitor for overfitting | | Weight Decay | 1e-4 to 1e-5 | L2 regularization | | Dropout | 0.2 to 0.5 | Before FC layers |
See scripts/training_loop_template.py for a complete training implementation.
Essential steps:
model.train())optimizer.zero_grad())loss.backward())optimizer.step())For evaluation:
model.eval())torch.no_grad() to disable gradient computation| Task | Loss Function |
|------|---------------|
| Multi-class classification | nn.CrossEntropyLoss() |
| Binary classification | nn.BCEWithLogitsLoss() |
| Regression | nn.MSELoss() |
| Task | Recommended Architecture | |------|-------------------------| | Image classification | CNN | | Object detection | CNN + additional heads | | Image segmentation | CNN with skip connections | | Time series | RNN, LSTM, or GRU | | Text generation | Transformer (LLM) | | Machine translation | Transformer encoder-decoder | | Image generation | Diffusion model | | Text-to-image | Diffusion + text encoder |
# Convolutional layer
nn.Conv2d(in_channels, out_channels, kernel_size, padding=0)
# Max pooling
nn.MaxPool2d(kernel_size=2, stride=2)
# Fully connected
nn.Linear(in_features, out_features)
# Dropout
nn.Dropout(p=0.5)
# RNN variants
nn.LSTM(input_size, hidden_size, num_layers)
n.GRU(input_size, hidden_size, num_layers)
# Resize images
transforms.Resize((height, width))
# Convert to tensor
transforms.ToTensor()
# Normalize
transforms.Normalize(mean, std)
# Data augmentation
transforms.RandomRotation(degrees)
transforms.ColorJitter(brightness, contrast)
For implementation help:
scripts/cnn_template.py for image tasksscripts/training_loop_template.py for trainingscripts/parameter_calculator.py to estimate model sizeFor concept questions, refer to the relevant section above.
testing
How to perform a House of Lore (small bin attack) heap exploitation. Use this skill whenever the user mentions heap exploitation, small bin attacks, fake chunks, glibc heap vulnerabilities, or needs to insert fake chunks into small bins for arbitrary read/write. Trigger for CTF challenges involving heap corruption, glibc 2.31+ exploitation, or when the user needs to bypass malloc sanity checks using fake chunk linking.
testing
How to perform House of Force heap exploitation attacks. Use this skill whenever the user mentions heap exploitation, House of Force, top chunk manipulation, arbitrary memory allocation, malloc manipulation, or wants to allocate chunks at specific addresses. Also trigger for CTF challenges involving heap overflows, top chunk size overwrites, or when the user needs to calculate evil_size for heap attacks. Make sure to use this skill for any binary exploitation task involving glibc heap manipulation, even if they don't explicitly say "House of Force".
tools
How to perform House of Einherjar heap exploitation to allocate memory at arbitrary addresses. Use this skill whenever the user mentions heap exploitation, glibc heap attacks, arbitrary memory allocation, off-by-one overflow exploitation, tcache poisoning, fast bin attacks, or any CTF challenge involving heap manipulation. This is essential for binary exploitation tasks where you need to control malloc() return addresses.
testing
How to identify, analyze, and exploit heap overflow vulnerabilities in binary exploitation challenges and real-world scenarios. Use this skill whenever the user mentions heap overflows, memory corruption, heap grooming, tcache poisoning, fast-bin attacks, or any heap-related vulnerability in CTF challenges, binary analysis, or security research. This skill covers heap overflow fundamentals, exploitation techniques, heap grooming strategies, and real-world CVE analysis.