explains .
and explains .
can check if the zero or more elements of the 1st 0D or more D tensor are equal or nearly equal to the zero or more elements of the 2nd 0D or more D tensor element-wise, getting the 0D or more D tensor of zero or more elements as shown below:
*Memos:
isclose()can be used with can check if two of 0D or more D tensors have the same size and elements, getting the scalar of a boolean value as shown below:
*Memos:
equal()can be used withtorchor a tensor.- The 1st argument(
input) withtorchor using a tensor(Required-Type:tensorofint,float,complexorbool). - The 2nd argument with
torchor the 1st argument with a tensor isother(Required-Type:tensorofint,float,complexorbool).
CODEimport torch
tensor1 = torch.tensor([5, 9, 3])
tensor2 = torch.tensor([5, 9, 3])
torch.equal(input=tensor1, other=tensor2)
tensor1.equal(other=tensor2)
torch.equal(input=tensor2, other=tensor1)
# True
tensor1 = torch.tensor([5, 9, 3])
tensor2 = torch.tensor([7, 9, 3])
torch.equal(input=tensor1, other=tensor2)
torch.equal(input=tensor2, other=tensor1)
# False
tensor1 = torch.tensor([5, 9, 3])
tensor2 = torch.tensor([[5, 9, 3]])
torch.equal(input=tensor1, other=tensor2)
torch.equal(input=tensor2, other=tensor1)
# False
tensor1 = torch.tensor([5., 9., 3.])
tensor2 = torch.tensor([5.+0.j, 9.+0.j, 3.+0.j])
torch.equal(input=tensor1, other=tensor2)
torch.equal(input=tensor2, other=tensor1)
# True
tensor1 = torch.tensor([1.+0.j, 0.+0.j, 1.+0.j])
tensor2 = torch.tensor([True, False, True])
torch.equal(input=tensor1, other=tensor2)
torch.equal(input=tensor2, other=tensor1)
# True
tensor1 = torch.tensor([], dtype=torch.int64)
tensor2 = torch.tensor([], dtype=torch.float32)
torch.equal(input=tensor1, other=tensor2)
torch.equal(input=tensor2, other=tensor1)
# True
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
SOCIAL SHARE CARD GENERATOR