bgraysea
(Brent)
January 14, 2021, 11:43am
1
Would like to confirm my understanding:
From
def get_data(n):
x = torch.randn(bs*n, 1)
return TensorDataset(x, a*x + b + 0.1*torch.randn(bs*n, 1))
is x
defining the independent input
and a*x + b + 0.1*torch.randn(bs*n, 1)
defining the label?
return TensorDataset(x, a*x + b + 0.1*torch.randn(bs*n, 1)) train_ds = get_data(n_train) valid_ds = get_data(n_valid) device = default_device() if cuda else None train_dl = TfmdDL(train_ds, bs=bs, shuffle=True, num_workers=0) valid_dl = TfmdDL(valid_ds, bs=bs, num_workers=0) return DataLoaders(train_dl, valid_dl, device=device) # Cell class RegModel(Module): def __init__(self): self.a,self.b = nn.Parameter(torch.randn(1)),nn.Parameter(torch.randn(1)) def forward(self, x): return x*self.a + self.b # Cell @delegates(Learner.__init__) def synth_learner(n_trn=10, n_val=2, cuda=False, lr=1e-3, data=None, model=None, **kwargs): if data is None: data=synth_dbunch(n_train=n_trn,n_valid=n_val, cuda=cuda) if model is None: model=RegModel() return Learner(data, model, lr=lr, loss_func=MSELossFlat(), opt_func=partial(SGD, mom=0.9), **kwargs)
yep x is the input and a*x + b + 0.1*torch.randn(bs*n, 1)
is the target. or you can also say x is the independent variable and a*x + b + 0.1*torch.randn(bs*n, 1)
is the dependent variable. lots of terms for the same thing…