Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-333

Dequantized Weight Reconstruction

Problem

Reconstruct weights from per-row integer codes and per-row scales: W[i][j] = codes[i][j] * scales[i]. Return the dequantized matrix.

The signature is dequantized_weight_reconstruction(codes, scales).

Hint

Each row has its own scale, so multiply row i by scales[i].

Test cases

case 1
in: [[[1,-2],[3,0]],[0.5,2]]
expected: [[0.5,-1],[6,0]]
case 2
in: [[[-1,0,1]],[1]]
expected: [[-1,0,1]]
case 3
in: [[[2]],[-0.5]]
expected: [[-1]]
case 4
in: [[[0,0],[0,0]],[1,2]]
expected: [[0,0],[0,0]]
Starter codePython
def dequantized_weight_reconstruction(codes, scales):
    # Your code here
    pass

4 test cases · run your code against them in the editor