Skip to main content
. 2023 Jan 5;23(2):634. doi: 10.3390/s23020634
Algorithm 1 Class activation mapping.
Require: Image IC(H,W); Network N
Ensure: Replace FC layer with average pooling layer in Network N
procedure CAM(I, N)
    N(I) ▹ Input image into network
    Wkc(w1,w2,w3,...,wk) ▹ Get weights from average polling layer
    Fkc(f1(x,y),f2(x,y),f3(x,y),...,fk(x,y)) ▹ Feature map of the last convolution layer
 layer
    Mc(x,y)=kwkcfk(x,y) ▹ Weighted linear summation
    Mc(x,y)=1HWiHjWMc(x,y) ▹ Normalize and up-sample to Network input size
    Mc(x,y)=Relu(Mc(x,y)) ▹ Final image heat map
end procedure