Pytorch does not pad the layers
While making a network I used deconvolution layer :
def deconv3d(cin,cout,k=4,s=2,pad=-1):
    pad = (k - 1) // 2 if pad &lt; 0 else pad
    return nn.Sequential(
        nn.ConvTranspose3d(cin,cout,kernel_size=k,stride=s,padding = pad,bias=False),
        nn.ReLU(inplace=True)
    )

And I adjusted this to networks and it keeps reducing the size of layer.
self.conv_f5 = conv3d(128, 128, k=3, s=1, pad=1)
    self.conv_f6 = deconv3d(128,64,k=3,s=2,pad=1) 
    self.conv_f7 = conv3d(64,64,k=3,s=1,pad=1)                                                        
    self.conv_f8 = deconv3d(64,32,k=3,s=2,pad=1)
    self.conv_f9 = conv3d(32,32,k=3,s=1,pad=1)

This is the layers I made and the result is :
Cost Volume: torch.Size([2, 128, 100, 120, 160])
fc5 torch.Size([2, 128, 50, 60, 80])
fc6 torch.Size([2, 64, 99, 119, 159])
fc8 torch.Size([2, 32, 197, 237, 317])

I cannot understand why f3 has smaller size than expected and finding how to fix it.
Please tell me how and thank you very much.

This is still not a reproducible example. I see there are calls to conv3d for which you have not provided the source code. I believe it is not a mere wrapper around nn.Conv3d because the resulting size does not match (self.conv_5for example should not change the tensor shape with its given parameters)
However I believe what puzzles you is the odd size ([2, 64, 99, 119, 159]). In that case you want to read very carefully the documentation for nn.ConvTranspose3d. In particular :
However, when stride &gt; 1, Conv3d maps multiple input shapes to the same output shape. output_padding is provided to resolve this ambiguity by effectively increasing the calculated output shape on one side. Note that output_padding is only used to find output shape, but does not actually add zero-padding to output.
According to the shape equation which is provided with the documentation, I believe you want to add an output_padding=1 to your deconv layers.
