Deep Learning · Module 1
Answers and explanations · Read a tensor before training a model
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
Deep Learning · Module 1
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
01A. The output has shape (1,2). First output: 2×2 + 0×(-1) + (-1)×0.5 + 0.5 = 4. Second: 2×(-1) + 0×0 + (-1)×1 - 0.5 = -3.5. A single observation still keeps a batch axis.
01B. Broadcasting gives (3,3), with rows [-1,-3,-5], [1,-1,-3], [3,1,-1]. Reshape targets with unsqueeze(1) to (3,1); corresponding-row subtraction gives three -1 differences. The fix is semantic pairing, not merely avoiding a runtime exception.
01C. Input (5,4), stored PyTorch weight (3,4), bias (3,), output (5,3). There are 12 weights plus 3 biases = 15 adjustable scalars. Batch size does not change parameter count.