Previous question · 225
Find All Anagrams in a String
mediumAlgorithms
Next question · 227
Latest Employee Login Info
easyDatabase
Random coding question

226. Vision transformer patch embedding

medium
GeneralGeneral
senior
Function contract
Inputs
W
np.ndarray
b
np.ndarray
image
np.ndarray
patch_size
int
Returns
value
np.ndarray

Examples

Input
{
  "W": [
    [
      0.1,
      -0.2,
      0
    ],
    [
      0,
      0.3,
      0.1
    ],
    [
      0.2,
      0,
      -0.1
    ],
    [
      -0.1,
      0.1,
      0.2
    ],
    [
      0.05,
      -0.05,
      0.05
    ],
    [
      0.15,
      0.2,
      -0.2
    ],
    [
      0,
      0.1,
      0
    ],
    [
      0.25,
      -0.1,
      0.1
    ]
  ],
  "b": [
    0.5,
    -0.5,
    1
  ],
  "image": [
    [
      [
        1,
        0.5
      ],
      [
        2,
        1.5
      ],
      [
        3,
        2.5
      ],
      [
        4,
        3.5
      ]
    ],
    [
      [
        5,
        4.5
      ],
      [
        6,
        5.5
      ],
      [
        7,
        6.5
      ],
      [
        8,
        7.5
      ]
    ],
    [
      [
        9,
        8.5
      ],
      [
        10,
        9.5
      ],
      [
        11,
        10.5
      ],
      [
        12,
        11.5
      ]
    ],
    [
      [
        13,
        12.5
      ],
      [
        14,
        13.5
      ],
      [
        15,
        14.5
      ],
      [
        16,
        15.5
      ]
    ]
  ],
  "patch_size": 2
}
Output
[
  [
    3.15,
    0.30000000000000004,
    1.05
  ],
  [
    4.45,
    1,
    1.35
  ],
  [
    8.350000000000001,
    3.1,
    2.25
  ],
  [
    9.65,
    3.8,
    2.55
  ]
]

Constraints

Hint 1
Hint 2
Hint 3
Roles
ML Engineer
AI Engineer
Data Scientist
Research Scientist
Companies
GeneralGeneral
Levels
senior
entry
Tags
vision-transformer
patch-embedding
numpy-linear-algebra
tensor-reshaping

Similar Questions

Linear Regressionmedium
ML Coding
Activation function relueasy
ML Coding
Text normalizationmedium
ML Coding
27 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