Update 연구중.py
Browse files134 unmodified lines1351361371381391401411421431441451461471481491501511526 unmodified lines159160161162163164165166167168169170171172173174175176177134 unmodified linesself.dim = dimself.ln_token = layers.LayerNormalization(epsilon=1e-6)self.ln_gate = layers.LayerNormalization(epsilon=1e-6) # 이름 변경self.ln_channel = layers.LayerNormalization(epsilon=1e-6)# Token Mixerself.token_fc1 = layers.Dense(seq_len * 2)self.token_fc2 = layers.Dense(seq_len)# Gating (Sigmoid) - Temperature 불필요self.gate_dense = layers.Dense(1)# Channel Mixerself.ch_fc1 = layers.Dense(self.dim * 4, activation='gelu')self.ch_fc2 = layers.Dense(self.dim)def call(self, x, training=None):6 unmodified linesy = tf.transpose(y_t, perm=[0, 2, 1])x = x + y# 2. Scalar Gating (수정됨)# Softmax의 1/N 희석 문제를 해결하기 위해 Sigmoid 사용y = self.ln_gate(x)gate = tf.nn.sigmoid(self.gate_dense(y)) # (B, L, 1) Range: 0~1y = y * gatex = x + y# 3. Channel Mixery = self.ln_channel(x)y = self.ch_fc1(y)y = self.ch_fc2(y)x = x + yreturn x134 unmodified lines1351361371381391401411421431441451461471486 unmodified lines155156157158159160161162163164165134 unmodified linesself.dim = dimself.ln_token = layers.LayerNormalization(epsilon=1e-6)self.ln_channel = layers.LayerNormalization(epsilon=1e-6)# Token Mixerself.token_fc1 = layers.Dense(seq_len * 4)self.token_fc2 = layers.Dense(seq_len)# Channel Mixerself.ch_fc1 = layers.Dense(self.dim * 4)self.ch_fc2 = layers.Dense(self.dim)def call(self, x, training=None):6 unmodified linesy = tf.transpose(y_t, perm=[0, 2, 1])x = x + yy = self.ln_channel(x)a, b = tf.split(self.ch_fc1(y), 2, axis=-1)y = self.ch_fc2(a * tf.nn.gelu(b))x = x + yreturn x
연구중.py+5-17