48. Small CNN Image Project in PyTorch
48.2 Synthesize Tiny Images
48.2 Synthesize tiny images
Download नको — memory मध्ये toy dataset बनावा.
हे का शिकायचं?
Why. Download नको. Memory मध्ये toy dataset बना — students practice करू शकतील.
हे काय आहे?
What. Class 0: डावी half जास्त bright. Class 1: उजवी half जास्त bright. Crude पण demo CNN साठी separable.
कसं करायचं?
How.
Tensors synthesize करा
- Zeros tensors create करा.
- Left किंवा right half fill करा.
- थोडा noise add करा.
- Stack labels.
import torch
def make_batch(n=64):
x = torch.rand(n, 1, 28, 28) * 0.2
y = torch.randint(0, 2, (n,))
for i in range(n):
if y[i] == 0:
x[i, 0, :, :14] += 0.8
else:
x[i, 0, :, 14:] += 0.8
return x, y
X, y = make_batch(8)
print(X.shape, y)