njs03332 / ml_study

3 stars 0 forks source link

2024/03/04 ~ 2024/03/17 #80

Open givitallugot opened 7 months ago

givitallugot commented 7 months ago

2024/03/17 (일) 10:00

1: 16.4 2: 16.4.1 3: 16.4.2 ~ (위치 인코딩까지)

givitallugot commented 7 months ago

assign roles -s 0304 -c 1 2 3

njs03332 commented 7 months ago
0 1 2
member 주선미 한단비 김유리
chapter 1 2 3
givitallugot commented 7 months ago

assign roles -s 0304 -c 1 2 3

njs03332 commented 7 months ago
0 1 2
member 주선미 한단비 김유리
chapter 1 2 3
danbi5228 commented 7 months ago

16.4.1 비주얼 어텐션

givitallugot commented 7 months ago

16.4 어텐션 메커니즘

njs03332 commented 7 months ago

16.4.2 트랜스포머 구조: 어텐션이 필요한 전부다

스크린샷 2024-03-17 오후 8 09 15

위치 인코딩

class PositionalEncoding(keras.layers.Layer):

  def __init__(self, max_steps, max_dims, dtype=tf.float32, **kwargs):
    super().__init__()
    if max_dims % 2 == 1: max_dims += 1
    p, i = np.meshgrid(np.arange(max_steps), np.arange(max_dims // 2))
    pos_emb = np.empty((1, max_steps, max_dims))
    pos_emb[0, :, ::2], = np.sin(p / 10000**(2*i/max_dims)).T
    pos_emb[0, :, 1::2] = np.cos(p / 10000**(2*i/max_dims)).T
    self.positional_embedding = tf.constant(pos_emb.astype(self.dtype))
  def call(self, inputs):
    shape = tf.shape(inputs)
    return inputs + self.positional_embedding[:, :shape[-2], :shape[-1]]