I want to implement instance normalization

I want to implement instance normalization



I am writing a metal cnn code.

Metal provides MPSCNNLocalContrastNormalization,

Since the concept of Instance Normalization is slightly different, I intend to implement it as a Kernel Function.



However, the problem is that the mean and variance for each R, G, B should be obtained when feature is R, G, B in texture received from input in kernel function.

I want to get some hints on how to implement this.

Replies

Hi @soo999,

Yes, you can use compute kernel to implement instance normalization with several method.

But mostly it is very slow.

And for mean and variance calculate you can use api PoolingAverage and kernel implementation

And R,G,B should be implemented by split kernel after blit encoder copy some slice from MPSImage.

Good luck