Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ flatten() and unbind() in PyTorch

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š flatten() and unbind() in PyTorch


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

flatten() can remove zero or more dimensions from a 0D or more tensor as shown below:

import torch

my_tensor = torch.tensor(2)

torch.flatten(my_tensor)
torch.flatten(my_tensor, 0, 0)
torch.flatten(my_tensor, 0, -1)
torch.flatten(my_tensor, -1, 0)
torch.flatten(my_tensor, -1, -1)
# tensor([2])

my_tensor= torch.tensor([2, 7, 4]) # 1D tensor

torch.flatten(my_tensor)
torch.flatten(my_tensor, 0, 0)
torch.flatten(my_tensor, 0, -1)
torch.flatten(my_tensor, -1, 0)
torch.flatten(my_tensor, -1, -1)
# tensor([2, 7, 4])

my_tensor = torch.tensor([[2, 7, 4], [8, 3, 2]]) # 2D tensor

torch.flatten(my_tensor)
torch.flatten(my_tensor, 0, 0)
torch.flatten(my_tensor, 0, 1)
torch.flatten(my_tensor, 0, -1)
torch.flatten(my_tensor, -1, 0)
torch.flatten(my_tensor, -1, -1)
torch.flatten(my_tensor, -2, 1)
torch.flatten(my_tensor, -2, -1)
# tensor([2, 7, 4, 8, 3, 2])

torch.flatten(my_tensor, 0, -2)
torch.flatten(my_tensor, 1, 1)
torch.flatten(my_tensor, 1, -1)
torch.flatten(my_tensor, -1, 1)
torch.flatten(my_tensor, -1, -1)
torch.flatten(my_tensor, -2, 0)
torch.flatten(my_tensor, -2, -2)
# tensor([[2, 7, 4], [8, 3, 2]])

my_tensor = torch.tensor([[[2, 7, 4], [8, 3, 2]], # 3D tensor
                          [[5, 0, 8], [3, 6, 1]]])
torch.flatten(my_tensor)
torch.flatten(my_tensor, 0, 2)
torch.flatten(my_tensor, 0, -1)
torch.flatten(my_tensor, -3, -1)
# tensor([2, 7, 4, 8, 3, 2, 5, 0, 8, 3, 6, 1])

torch.flatten(my_tensor, 0, 0)
torch.flatten(my_tensor, 0, -3)
torch.flatten(my_tensor, 1, 1)
torch.flatten(my_tensor, 1, -2)
torch.flatten(my_tensor, 2, 2)
torch.flatten(my_tensor, 2, -1)
torch.flatten(my_tensor, -1, 2)
torch.flatten(my_tensor, -1, -1)
torch.flatten(my_tensor, -2, 1)
torch.flatten(my_tensor, -2, -2)
torch.flatten(my_tensor, -3, 0)
torch.flatten(my_tensor, -3, -3)
# tensor([[[2, 7, 4], [8, 3, 2]],
#         [[5, 0, 8], [3, 6, 1]]])

torch.flatten(my_tensor, 0, 1)
torch.flatten(my_tensor, 0, -2)
torch.flatten(my_tensor, -3, 1)
torch.flatten(my_tensor, -3, 2)
torch.flatten(my_tensor, -3, -2)
# tensor([[2, 7, 4], [8, 3, 2], [5, 0, 8], [3, 6, 1]])

torch.flatten(my_tensor, 1, 2)
torch.flatten(my_tensor, 1, -1)
torch.flatten(my_tensor, -2, 2)
torch.flatten(my_tensor, -2, -1)
# tensor([[2, 7, 4, 8, 3, 2],
#         [5, 0, 8, 3, 6, 1]])

*Memos:

  • The 2nd argument is the 1st dimension.
  • The 3rd argument is the last dimension.
  • flatten() can be called both from torch and a tensor.

unbind() can remove a dimension from 1D or more D tensor as shown below:

import torch

my_tensor= torch.tensor([2, 7, 4]) # 1D tensor

torch.unbind(my_tensor)
torch.unbind(my_tensor, 0)
torch.unbind(my_tensor, -1)
# (tensor(2), tensor(7), tensor(4))

my_tensor = torch.tensor([[2, 7, 4], [8, 3, 2]]) # 2D tensor

torch.unbind(my_tensor)
torch.unbind(my_tensor, 0)
torch.unbind(my_tensor, -2)
# (tensor([2, 7, 4]), tensor([8, 3, 2]))

torch.unbind(my_tensor, 1)
torch.unbind(my_tensor, -1)
# (tensor([2, 8]), tensor([7, 3]), tensor([4, 2]))

my_tensor = torch.tensor([[[2, 7, 4], [8, 3, 2]], # 3D tensor
                          [[5, 0, 8], [3, 6, 1]]])
torch.unbind(my_tensor)
torch.unbind(my_tensor, 0)
torch.unbind(my_tensor, -3)
# (tensor([[2, 7, 4], [8, 3, 2]]),
#  tensor([[5, 0, 8], [3, 6, 1]]))

torch.unbind(my_tensor, 1)
torch.unbind(my_tensor, -2)
# (tensor([[2, 7, 4], [5, 0, 8]]),
#  tensor([[8, 3, 2], [3, 6, 1]]))

torch.unbind(my_tensor, 2)
torch.unbind(my_tensor, -1)
# (tensor([[2, 8], [5, 3]]),
#  tensor([[7, 3], [0, 6]]),
#  tensor([[4, 2], [8, 1]]))

*Memos:

  • The 2nd argument is dimension.
  • unbind() can be called both from torch and a tensor.
...



๐Ÿ“Œ flatten() and unbind() in PyTorch


๐Ÿ“ˆ 76.21 Punkte

๐Ÿ“Œ Medium CVE-2020-7713: Arr-flatten-unflatten project Arr-flatten-unflatten


๐Ÿ“ˆ 51.33 Punkte

๐Ÿ“Œ unbind() and tensor_split() in PyTorch


๐Ÿ“ˆ 50.54 Punkte

๐Ÿ“Œ chunk() and unbind() in PyTorch


๐Ÿ“ˆ 50.54 Punkte

๐Ÿ“Œ flatten() and unflatten() in PyTorch


๐Ÿ“ˆ 42.97 Punkte

๐Ÿ“Œ Learn You a PyTorch! (aka Introduction Into PyTorch)


๐Ÿ“ˆ 31.03 Punkte

๐Ÿ“Œ PyTorch on Azure: Full support for PyTorch 1.2


๐Ÿ“ˆ 31.03 Punkte

๐Ÿ“Œ PyTorch Lightning 1.0: PyTorch, nur schneller und flexibler


๐Ÿ“ˆ 31.03 Punkte

๐Ÿ“Œ Pytorch: Microsoft startet neuen Azure-Service Pytorch Enterprise


๐Ÿ“ˆ 31.03 Punkte

๐Ÿ“Œ Use the Defense Production Act to Flatten the Curve


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ Wofรผr steht "flatten the curve"? Erklรคrung und Verwendung


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ Tech's Early Work-From-Home Mandates Helped California, Washington Flatten Curve


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ arr-flatten-unflatten on npm Prototype privileges management


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ Numpy Tutorial #9 - Ravel und Flatten (Python fรผr Data Science)


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ List Flatten in Python โ€“ Flattening Nested Lists


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ An Australian Model to Address Climate-Related Displacement: How to Flatten the Curve


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ How to flatten InDesign File for print


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ Don't flatten yourself restoring malware with Control Flow Flattening obfuscation - Geri Revay


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ Stompy - Timestomp Tool To Flatten MAC Times With A Specific Timestamp


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ How to flatten a PHP array


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ Flatten Nested Arrays With PHP


๐Ÿ“ˆ 25.67 Punkte

๐Ÿ“Œ Structure and Relationships: Graph Neural Networks and a Pytorch Implementation


๐Ÿ“ˆ 19.09 Punkte

๐Ÿ“Œ PyTorch 1.0: Now and in the Future || Adam Paszke


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ What is PyTorch? And why you should learn it?


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ AI Show Live - Episode 65 - Azure Form Recognizer, Deep Learning Container with PyTorch and AzureML


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ Developer preview, PyTorch models, and more dev news!


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ Deep Learning Container with PyTorch and Azure ML


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ Loading and Providing Datasets in PyTorch


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ [$] PyTorch and the PyPI supply chain


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ This week in Open Source - Two Tiny Linux PCs, RISC-V for IoT, Fedora 38, PyTorch 2.0, and more


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ Training a custom YOLOv7 in PyTorch and running it directly in the browser with TensorFlow.js


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ Editing Images Via A Prompt With Python And Pytorch


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ How Pytorch 2.0 accelerates deep learning with operator fusion and CPU/GPU code-generation


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ Intuitivo achieves higher throughput while saving on AI/ML costs using AWS Inferentia and PyTorch


๐Ÿ“ˆ 17.3 Punkte

๐Ÿ“Œ Android Neural Networks API 1.3 and PyTorch Mobile support


๐Ÿ“ˆ 17.3 Punkte











matomo