Can you tell me  in this layer nn.Conv2d(1, kernel, 3, stride=1, padding=1)
what is 3 for ?
and your output formula is quit incorrect out = (in-k+2*p)/s + 1 should be
out = (in-k+2*p)/(2*s) + 1
what is the size of your images?