I've noticed that you can often invoke a method working with tensors from the torch module itself, or call it as a bound method on an instance of a torch tensor.
For instance:
import torch
my_tens = torch.ones((3,2))
another_tens = torch.ones((3,2))
res_tens = my_tens==another_tens
# both are equivalent:
torch.all(res_tens, dim=1)
res_tens.all(dim=1)
Similarly, .sum()
and other methods work the same way. Why is that? Are there any advantages to using one approach or the other?
Aucun commentaire:
Enregistrer un commentaire