Previous question · 1081
Reverse Nodes In K Group
hardData Structures
Next question · 1083
Decode Ways
mediumAlgorithms
Random coding question

1082. Masked attention scores

medium
GeneralGeneral
staff
Function contract
Inputs
K
np.ndarray
Q
np.ndarray
mask
np.ndarray
Returns
value
np.ndarray

Examples

Input
{
  "K": [
    [
      1,
      0
    ],
    [
      0,
      1
    ]
  ],
  "Q": [
    [
      1,
      0
    ],
    [
      0,
      1
    ]
  ],
  "mask": [
    [
      1,
      0
    ],
    [
      1,
      1
    ]
  ]
}
Output
[
  [
    1,
    0
  ],
  [
    0.3302384506733431,
    0.6697615493266569
  ]
]

Constraints

Hint 1
Hint 2
Hint 3
Roles
ML Engineer
AI Engineer
Data Scientist
Research Scientist
Companies
GeneralGeneral
Levels
staff
senior
entry
Tags
scaled-dot-product-attention
masking
numerically-stable-softmax
numpy-matrix-multiplication

Similar Questions

Linear Regressionmedium
ML Coding
Activation function relueasy
ML Coding
Text normalizationmedium
ML Coding
48 people are solving this problem
Loading editor for the selected language
Ln 1, Col 1
Program Output
DATAINTERVIEW
Interactive coding terminal
Python / NumPy environment ready.
Type a command below or run code from the editor.
run scriptExecute the current editor contents
submitGrade the current editor contents against all solution test cases
python ("print hello world")Run an isolated Python command
helpShow all available commands