Thanks for your help! The second approach appears to be exactly what I’m looking for and produces a vector of 8.
The first approach also works but for my purposes it wouldn’t need the .expand_as().
Thanks again for your help, as a PyTorch beginner it’s very useful to see two approaches that achieve the same result.