All problems
SmoothQuant Scaled Weights
Problem
Apply SmoothQuant channel scaling to both weights and activations. Multiply each weight column by its smoothing factor s_j and divide each activation column by the same factor: W_scaled[i][j] = W[i][j]*s_j and X_scaled[i][j] = X[i][j]/s_j. Return [W_scaled, X_scaled].
The signature is smoothquant_scaled_weights(W, X, s).
Hint
The product W_scaled * X_scaled equals W * X, so the layer output is unchanged.
Test cases
case 1
in: [[[1,2]],[[2,4]],[2,4]]
expected: [[[2,8]],[[1,1]]]
case 2
in: [[[1,1],[1,1]],[[1,1]],[0.5,2]]
expected: [[[0.5,2],[0.5,2]],[[2,0.5]]]
case 3
in: [[[2,4]],[[1,1]],[1,1]]
expected: [[[2,4]],[[1,1]]]
Starter codePython
def smoothquant_scaled_weights(W, X, s):
# Your code here
pass3 test cases · run your code against them in the editor