Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Implementing Scaled Dot-Product Attention | Section
Transformer Architecture

bookChallenge: Implementing Scaled Dot-Product Attention

Pyyhkäise näyttääksesi valikon

Task

You now have all the pieces to implement scaled dot-product attention from scratch. Using the formula from the previous chapter, write a function scaled_dot_product_attention that:

  1. Takes Q, K, V tensors of shape (batch_size, seq_len, d_k) as input;
  2. Accepts an optional mask tensor of shape (batch_size, seq_len_q, seq_len_k) — when provided, positions where mask == 0 should be set to -inf before softmax;
  3. Returns the output tensor and the attention weights.

Implement the function locally.

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 3

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Osio 1. Luku 3
some-alt