I don’t see any obvious problems here but you can do some simple tests like running your layer on a ones tensor input and checking that the results are what you expect based on the mask. If you are using batchnorm layers after the convolution, you can avoid the bias term entirely as it will be effectively undone by the batchnorm. Additionally, I don’t think the bias is applied before the convolution, so it shouldn’t be affected by (or affect) the mask that you are using.