MATLABTIPS Telegram 1710
اما وقتی با تانسورهایی با بیش از دو بعد کار می‌کنیم، دیگر "سطر" و "ستون" معنا ندارد چون ابعاد بیشتر شده‌اند. مثلاً در یک تانسور با شکل (B,T,D) نمی‌توان به‌سادگی گفت کدام "سطر" است و کدام "ستون" — بنابراین به‌جای transpose، از تابعی به‌نام permute یا transpose(dim1, dim2) استفاده می‌شود.

x = torch.randn(32, 64, 128)  # shape: (B, T, D)
x_t = x.transpose(1, 2) # shape: (B, D, T)


ترتیب‌دهی مجدد کامل ابعاد تانسور:
x = torch.randn(32, 64, 128)
x_perm = x.permute(2, 0, 1) # shape: (128, 32, 64)


در attention ما معمولاً کاری مثل این انجام می‌دهیم:
Q @ K.transpose(-2, -1)


اگر دقت کنید ما فقط نیاز داریم که دو محور آخر را جابجا کنیم (با محور اول که برای batch ست کاری نداریم). حتما کد های بالا را اجرا کنید تا متوجه تفاوت بشوید



tgoop.com/matlabtips/1710
Create:
Last Update:

اما وقتی با تانسورهایی با بیش از دو بعد کار می‌کنیم، دیگر "سطر" و "ستون" معنا ندارد چون ابعاد بیشتر شده‌اند. مثلاً در یک تانسور با شکل (B,T,D) نمی‌توان به‌سادگی گفت کدام "سطر" است و کدام "ستون" — بنابراین به‌جای transpose، از تابعی به‌نام permute یا transpose(dim1, dim2) استفاده می‌شود.

x = torch.randn(32, 64, 128)  # shape: (B, T, D)
x_t = x.transpose(1, 2) # shape: (B, D, T)


ترتیب‌دهی مجدد کامل ابعاد تانسور:
x = torch.randn(32, 64, 128)
x_perm = x.permute(2, 0, 1) # shape: (128, 32, 64)


در attention ما معمولاً کاری مثل این انجام می‌دهیم:
Q @ K.transpose(-2, -1)


اگر دقت کنید ما فقط نیاز داریم که دو محور آخر را جابجا کنیم (با محور اول که برای batch ست کاری نداریم). حتما کد های بالا را اجرا کنید تا متوجه تفاوت بشوید

BY MatlabTips


Share with your friend now:
tgoop.com/matlabtips/1710

View MORE
Open in Telegram


Telegram News

Date: |

Telegram offers a powerful toolset that allows businesses to create and manage channels, groups, and bots to broadcast messages, engage in conversations, and offer reliable customer support via bots. Avoid compound hashtags that consist of several words. If you have a hashtag like #marketingnewsinusa, split it into smaller hashtags: “#marketing, #news, #usa. End-to-end encryption is an important feature in messaging, as it's the first step in protecting users from surveillance. Earlier, crypto enthusiasts had created a self-described “meme app” dubbed “gm” app wherein users would greet each other with “gm” or “good morning” messages. However, in September 2021, the gm app was down after a hacker reportedly gained access to the user data. There have been several contributions to the group with members posting voice notes of screaming, yelling, groaning, and wailing in different rhythms and pitches. Calling out the “degenerate” community or the crypto obsessives that engage in high-risk trading, Co-founder of NFT renting protocol Rentable World emiliano.eth shared this group on his Twitter. He wrote: “hey degen, are you stressed? Just let it out all out. Voice only tg channel for screaming”.
from us


Telegram MatlabTips
FROM American