Deep-learning framework · dynamic + static graphs · PyTorch-like eager API · verified against PaddlePaddle 3.x (2026)

PaddlePaddle cheat sheet

PaddlePaddle (飞桨) is Baidu's deep-learning framework. Its Python API mirrors PyTorch's eager style: build models by subclassing paddle.nn.Layer, run them imperatively (dygraph), and train with a backward()opt.step() loop. When you're ready to ship, @paddle.jit.to_static traces the same code into a static graph (accelerated by the CINN compiler) for deployment — the "unified dynamic/static" design. A high-level paddle.Model API gives Keras-style fit. Targets PaddlePaddle 3.x, Python 3.9+.

tensors & setup build models train loop high-level & data deploy & ecosystem gotcha most common

Verified 2026-08-31 against the official docs at paddlepaddle.org.cn (PaddlePaddle 3.x; latest 3.3.x, 2026). API deliberately close to PyTorch — note the spellings: paddle.nn.Layer (not Module), Conv2D (capital D), optimizer(parameters=...), opt.clear_grad().

Outline

Tensors, then a nn.Layer model, then the eager train loop. Reach for paddle.Model when you want Keras-style training, and jit.to_static for deployment.

Tensors & setup

  1. 1Install & device
  2. 2Tensors

Build models

  1. 3nn.Layer models
  2. 4Layers & functional

Training

  1. 5Losses & optimizers
  2. 6The training loop
  3. 7Save, load & eval

High-level & data

  1. 8Datasets & DataLoader
  2. 9paddle.Model (Keras-style)

Deploy & ecosystem

  1. 10Dynamic → static & AMP
  2. 11Inference & deploy
  3. 12Ecosystem

Tensors & Setup

Install the right wheel for your hardware; tensors work like NumPy/PyTorch.

1Install & devicepip / GPU
2Tensorslike NumPy

Build Models

Subclass nn.Layer; compose the built-in layers or drop to functional ops.

3nn.Layer modelssubclass it
4Layers & functionalbuilding blocks

Training

Losses, optimizers, and the eager backward/step/clear_grad loop.

5Losses & optimizersthe pieces
6The training loopeager mode
7Save, load & evalcheckpoints

High-level & Data

Feed data with the standard pipeline, or skip the loop with paddle.Model.

8Datasets & DataLoaderfeeding data
9paddle.Model (Keras-style)skip the loop

Deploy & Ecosystem

Trace to a static graph, speed up with AMP/CINN, then export for inference.

10Dynamic → static & AMPspeed
11Inference & deployship it
12Ecosystemthe model suites

Worth memorizing

import paddleeager (dygraph) mode on by default
paddle.to_tensorbuild tensors; .numpy() to go back
nn.Layerbase class (Paddle's nn.Module)
Conv2D / BatchNorm2Dcapital D — porting gotcha
F.cross_entropyCrossEntropyLoss takes raw logits
optimizer(parameters=,learning_rate=) — not params/lr
loopbackward() → step() → clear_grad()
clear_grad()Paddle's zero_grad — don't forget it
save/set_state_dict.pdparams weights, .pdopt optimizer
paddle.Modelprepare / fit / evaluate (Keras-style)
@jit.to_staticeager → static graph (CINN) for deploy
PaddleOCRthe ecosystem's flagship toolkit