Hi.
I recently realized that nn.Linear can handle multi-dimension tensor.
However, it seems that I do not fully understand the computation process in the linear layer (or matrix multiplication something…)
multi_dim_layer778×301 38.5 KB
In the example code above, I have (3 * 100 = 300) numbers of 512-dimension vectors.
result1 is the result of directly forwarding the multi dimension tensor to the linear layer.
result2 is the result of iteratively(100) forwarding (3 X 512) tensor to the linear layer and stacked them.
The two results are similar but not the same as you can see in the output of the code.
Why the two computation yields different results?