All problems
Per-Channel Softmax Map
Problem
Apply softmax over the class dimension of an H x W x C score map.
For each pixel subtract the maximum score before exponentiating for numerical stability, then normalize the exponentials and round each probability to 4 decimal places.
Hint
Subtracting the max keeps the exponentials from overflowing.
Test cases
case 1
in: [[[[1,1]]]]
expected: [[[0.5,0.5]]]
case 2
in: [[[[0,0,0]]]]
expected: [[[0.3333,0.3333,0.3333]]]
case 3
in: [[[[1000,1000]]]]
expected: [[[0.5,0.5]]]
case 4
in: [[[[1,3],[2,0]]]]
expected: [[[0.1192,0.8808],[0.8808,0.1192]]]
Starter codePython
def softmax_map(scores):
# Your code here
pass4 test cases · run your code against them in the editor