Lesson 3 of 8 · 2 min
Patches are words
A 32 by 32 picture cut into 4 by 4 patches gives 64 tokens.
import numpy as np image = np.arange(32 * 32 * 3).reshape(32, 32, 3) p = 4 patches = image.reshape(32 // p, p, 32 // p, p, 3).transpose(0, 2, 1, 3, 4).reshape(-1, p * p * 3) print(patches.shape)
