Ravindra BagaleCourses & study guides English Track your progress

48. Small CNN Image Project in PyTorch

Data Science

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 करा

  1. Zeros tensors create करा.
  2. Left किंवा right half fill करा.
  3. थोडा noise add करा.
  4. 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)