Herschel555 / CAML

repository for CAML: Correlation-aware mutual learning for semi-supervised medical image segmentation
32 stars 1 forks source link

code have a bug #1

Closed UsersNGT closed 1 year ago

UsersNGT commented 1 year ago

when i print the net use net = CAML3d_v1(1,2) print(net) ,An error has occurred,the bug is out range in code def get_dim(self, idx): if idx == 4: print(self.block_four) return self.block_four.conv[6].weight.shape[0], i print the self.block_four, is legth 6. so you out range.

ConvBlock( (conv): Sequential( (0): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1)) (1): ReLU(inplace=True) (2): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1)) (3): ReLU(inplace=True) (4): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1)) (5): ReLU(inplace=True) ) )

Herschel555 commented 1 year ago

Hi, you should use net = CAML3d_v1(1, 2, 'batchnorm') to instantiate the network instead of using net = CAML3d_v1(1, 2), or BatchNormalization would be set to None, resulting in its absence from the ConvBlock.

The following is an example of modules in a ConvBlock that instantiates correctly:

ConvBlock(
  (conv): Sequential(
    (0): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1))
    (1): BatchNorm3d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (2): ReLU(inplace=True)
    (3): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1))
    (4): BatchNorm3d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (5): ReLU(inplace=True)
    (6): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1))
    (7): BatchNorm3d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (8): ReLU(inplace=True)
  )
)
UsersNGT commented 1 year ago

Hi, you should use net = CAML3d_v1(1, 2, 'batchnorm') to instantiate the network instead of using net = CAML3d_v1(1, 2), or BatchNormalization would be set to None, resulting in its absence from the ConvBlock.

The following is an example of modules in a ConvBlock that instantiates correctly:

ConvBlock(
  (conv): Sequential(
    (0): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1))
    (1): BatchNorm3d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (2): ReLU(inplace=True)
    (3): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1))
    (4): BatchNorm3d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (5): ReLU(inplace=True)
    (6): Conv3d(128, 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1))
    (7): BatchNorm3d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
    (8): ReLU(inplace=True)
  )
)

Oh, oh, that's it. Thank you for your reply. I just want to print the network without setting default parameters. Thank you.