<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>derwind</author_name>
  <author_url>https://blog.hatena.ne.jp/derwind/</author_url>
  <blog_title>らんだむな記憶</blog_title>
  <blog_url>https://randommemory.hatenablog.com/</blog_url>
  <categories>
    <anon>machine_learning</anon>
  </categories>
  <description>torch.nn.Transformer の自己注意ブロックの実装を見ると、transformer.py#L352 のようになっている。 # self-attention block def _sa_block(self, x: Tensor, attn_mask: Optional[Tensor], key_padding_mask: Optional[Tensor]) -&gt; Tensor: x = self.self_attn(x, x, x, 他の実装サンプルも同様の実装である。つまり、Q-K-V に同じテンソルを渡している。この効果について Attention (4) - らんだむな記…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Frandommemory.hatenablog.com%2Fentry%2F2022%2F03%2F05%2F180312&quot; title=&quot;自己注意 - らんだむな記憶&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2022-03-05 18:03:12</published>
  <title>自己注意</title>
  <type>rich</type>
  <url>https://randommemory.hatenablog.com/entry/2022/03/05/180312</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
