Model Pipeline - Tensor shapes and dimensions
This pipeline shows how data moves through a simple PyTorch model, focusing on how tensor shapes change at each step. Understanding tensor shapes helps us avoid errors and design models correctly.
This pipeline shows how data moves through a simple PyTorch model, focusing on how tensor shapes change at each step. Understanding tensor shapes helps us avoid errors and design models correctly.
Epoch 1: 1.85 ***** Epoch 2: 1.20 **** Epoch 3: 0.85 *** Epoch 4: 0.65 ** Epoch 5: 0.50 *
| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.85 | 0.35 | Loss starts high, accuracy low as model begins learning |
| 2 | 1.20 | 0.55 | Loss decreases, accuracy improves as model learns features |
| 3 | 0.85 | 0.70 | Model continues to improve, loss drops steadily |
| 4 | 0.65 | 0.78 | Good convergence, accuracy nearing 80% |
| 5 | 0.50 | 0.85 | Model well trained, loss low and accuracy high |
t in PyTorch?t.size() returns the shape of the tensor as a tuple-like object.t.shape is an attribute, not a method, so t.shape() is incorrect. shape(t) and t.get_shape() are not valid PyTorch syntax.torch.randn(3, 4, 5)?import torch t = torch.randn(2, 3) print(t.shape())
t.shape is an attribute, not a method, so calling t.shape() tries to call a non-callable object.x with shape (10, 5, 3). You want to reshape it to a 2D tensor with 5 rows and keep the total number of elements the same. Which of the following shapes is valid for the reshaped tensor?Pass the test and this pattern moves unknown