<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=Self-Attention</id>
	<title>Self-Attention - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://monobook.org/w/index.php?action=history&amp;feed=atom&amp;title=Self-Attention"/>
	<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Self-Attention&amp;action=history"/>
	<updated>2026-07-23T03:39:14Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://monobook.org/w/index.php?title=Self-Attention&amp;diff=20485&amp;oldid=prev</id>
		<title>2024年4月11日 (木) 01:33にAdministratorによる</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Self-Attention&amp;diff=20485&amp;oldid=prev"/>
		<updated>2024-04-11T01:33:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2024年4月11日 (木) 01:33時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l6&quot;&gt;6行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;6行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;def self_attention(input, mask=None):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;def self_attention(input, mask=None):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     # Query, Key, Valueの計算&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     # Query, Key, Valueの計算&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     # まず入力からQuery、Key、Valueを計算します。&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     # まず入力からQuery、Key、Valueを計算します。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Administrator</name></author>
	</entry>
	<entry>
		<id>https://monobook.org/w/index.php?title=Self-Attention&amp;diff=20484&amp;oldid=prev</id>
		<title>Administrator: ページの作成:「&#039;&#039;&#039;Self-Attention&#039;&#039;&#039;とは、Transformerの中核となっている部分です。  == 擬似コード == Self-Attentionの基本的な構造は以下のように表…」</title>
		<link rel="alternate" type="text/html" href="https://monobook.org/w/index.php?title=Self-Attention&amp;diff=20484&amp;oldid=prev"/>
		<updated>2024-04-11T01:33:30Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「&amp;#039;&amp;#039;&amp;#039;Self-Attention&amp;#039;&amp;#039;&amp;#039;とは、&lt;a href=&quot;/wiki/Transformer&quot; title=&quot;Transformer&quot;&gt;Transformer&lt;/a&gt;の中核となっている部分です。  == 擬似コード == Self-Attentionの基本的な構造は以下のように表…」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Self-Attention&amp;#039;&amp;#039;&amp;#039;とは、[[Transformer]]の中核となっている部分です。&lt;br /&gt;
&lt;br /&gt;
== 擬似コード ==&lt;br /&gt;
Self-Attentionの基本的な構造は以下のように表現できます。&lt;br /&gt;
なお、このコードはPythonの擬似コードであり実際には動作しません。&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def self_attention(input, mask=None):&lt;br /&gt;
    # Query, Key, Valueの計算&lt;br /&gt;
    # まず入力からQuery、Key、Valueを計算します。&lt;br /&gt;
    # これらはそれぞれ異なる全結合層（query_projection、key_projection、value_projection）によって計算されます。&lt;br /&gt;
    queries = query_projection(input)&lt;br /&gt;
    keys = key_projection(input)&lt;br /&gt;
    values = value_projection(input)&lt;br /&gt;
    &lt;br /&gt;
    # スコアの計算&lt;br /&gt;
    # 次にQueryとKeyの内積を計算しスコアを得ます。&lt;br /&gt;
    # このスコアは各入力トークンが他のすべてのトークンとどの程度関連しているかを示します。  &lt;br /&gt;
    scores = matmul(queries, keys.transpose())&lt;br /&gt;
    &lt;br /&gt;
    # スコアをスケーリング&lt;br /&gt;
    # d_kは内積が大きくなりすぎてSoftmax関数が非常に小さな勾配を持つようになる&lt;br /&gt;
    # （つまり、勾配消失問題が発生する）のを防ぐためのスケーリングファクターです。。&lt;br /&gt;
    # d_kは通常、Query、Key、Valueの次元数です。&lt;br /&gt;
    d_k = 64&lt;br /&gt;
    scores = scores / sqrt(d_k)&lt;br /&gt;
    &lt;br /&gt;
    # マスクを適用（必要な場合）&lt;br /&gt;
    if mask is not None:&lt;br /&gt;
        scores = scores.masked_fill(mask == 0, -1e9)&lt;br /&gt;
    &lt;br /&gt;
    # スコアを確率分布に変換&lt;br /&gt;
    # スコアをSoftmax関数に通すことで確率分布（attention_weights）を得ます。&lt;br /&gt;
    attention_weights = softmax(scores)&lt;br /&gt;
    &lt;br /&gt;
    # Valueとの重み付き和を計算&lt;br /&gt;
    output = matmul(attention_weights, values)&lt;br /&gt;
    &lt;br /&gt;
    return output&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[category: 人工知能]]&lt;/div&gt;</summary>
		<author><name>Administrator</name></author>
	</entry>
</feed>