🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🪟 Windows TippsSetting up live captions stuck in Windows 11(14.09.2026 um 16:31 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsWindows 11's latest update broke my speakers, and I'm not alone(14.09.2026 um 18:54 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
🪟 Windows TippsSetting up live captions stuck in Windows 11(14.09.2026 um 16:31 Uhr)
🕵️ SicherheitslückenBurn Out, Or Fade Away(14.09.2026 um 14:25 Uhr)
🪟 Windows TippsWindows 11's latest update broke my speakers, and I'm not alone(14.09.2026 um 18:54 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 3 Min Lesezeit
0

isclose in PyTorch

↗ Quelle (dev.to)
🗣️ Stimme:

explains and explains .


  • and 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 torch or a tensor.

    • The 1st argument(input) with torch or using a tensor(Required-Type:tensor of int, float, complex or bool).

    • The 2nd argument with torch or the 1st argument with a tensor is other(Required-Type:tensor of int, float, complex or bool).

    • The 3rd argument with torch or the 2nd argument with a tensor is rtol(Optional-Default:1e-05-Type:float).

    • The 4th argument with torch or the 3rd argument with a tensor is atol(Optional-Default:1e-08-Type:float).

    • The 5th argument with torch or the 4th argument with a tensor is equal_nan(Optional-Default:False-Type:bool).

    • The formula is |input - other| <= rtol x |other| + atol.




    CODE
    import torch

    tensor1 = torch.tensor([1.00001001, 1.00000996, 1.00000995, torch.nan])
    tensor2 = torch.tensor([1., 1., 1., torch.nan])

    torch.isclose(input=tensor1, other=tensor2)
    torch.isclose(input=tensor1, other=tensor2,
    rtol=1e-05, atol=1e-08, equal_nan=False)
    # 0.00001 # 0.00000001
    tensor1.isclose(other=tensor2)
    torch.isclose(input=tensor2, other=tensor1)
    # tensor([False, False, True, False])

    torch.isclose(input=tensor1, other=tensor2, equal_nan=True)
    # tensor([False, False, True, True])

    tensor1 = torch.tensor([[1.00001001, 1.00000996],
    [1.00000995, torch.nan]])
    tensor2 = torch.tensor([[1., 1.],
    [1., torch.nan]])
    torch.isclose(input=tensor1, other=tensor2)
    # tensor([[False, False],
    # [True, False]])

    tensor1 = torch.tensor([[[1.00001001],
    [1.00000996]],
    [[1.00000995],
    [torch.nan]]])
    tensor2 = torch.tensor([[[1.], [1.]],
    [[1.], [torch.nan]]])
    torch.isclose(input=tensor1, other=tensor2)
    # tensor([[[False], [False]],
    # [[True], [False]]])

    tensor1 = torch.tensor([[1.00001001, 1.00000996],
    [1.00000995, torch.nan]])
    tensor2 = torch.tensor([1., 1.])

    torch.isclose(input=tensor1, other=tensor2)
    # tensor([[False, False],
    # [True, False]])

    tensor1 = torch.tensor([[1.00001001, 1.00000996],
    [1.00000995, torch.nan]])
    tensor2 = torch.tensor(1.)

    torch.isclose(input=tensor1, other=tensor2)
    # tensor([[False, False],
    # [True, False]])

    tensor1 = torch.tensor([])
    tensor2 = torch.tensor([])

    torch.equal(input=tensor1, other=tensor2)
    # True

    tensor1 = torch.tensor([])
    tensor2 = torch.tensor([[]])

    torch.equal(input=tensor1, other=tensor2)
    # False

    tensor1 = torch.tensor([0, 1, 2])
    tensor2 = torch.tensor(1)

    torch.isclose(input=tensor1, other=tensor2)
    # tensor([False, True, False])

    tensor1 = torch.tensor([0.+0.j, 1.+0.j, 2.+0.j])
    tensor2 = torch.tensor(1.+0.j)

    torch.isclose(input=tensor1, other=tensor2)
    # tensor([False, True, False])

    tensor1 = torch.tensor([False, True, False])
    tensor2 = torch.tensor(True)

    torch.isclose(input=tensor1, other=tensor2)
    # tensor([False, True, False])


    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
  • Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    1 Quelle
    The Gemini desktop app is now available for Windows
    1 Quelle
    Setting up live captions stuck in Windows 11
    1 Quelle
    Burn Out, Or Fade Away
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten isclose in PyTorch

    Thematisch verwandte Begriffe: isclose, PyTorch · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...