I’m not completely sure about the shapes you are using, but “3d images” should have 5 dimensions as [batch_size, channels, depth, height, width]
.
Your current padding call would pad the depth, height, and width dimension. Not the batch and channels dimensions. In the code snippet to compare some outputs, it seems you are trying to index the batch, channel, and depth dimensions, which seems to be wrong.
Could you check the shape before and after padding and rerun the comparison?