Skip to content

Commit 2b0a95e

Browse files
authored
auto updates (#7105)
Signed-off-by: monai-bot <monai.miccai2019@gmail.com> Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
1 parent 7930f85 commit 2b0a95e

7 files changed

Lines changed: 15 additions & 16 deletions

File tree

monai/apps/auto3dseg/bundle_gen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
logger = get_logger(module_name=__name__)
4848
ALGO_HASH = MONAIEnvVars.algo_hash()
4949

50-
5150
__all__ = ["BundleAlgo", "BundleGen"]
5251

5352

monai/apps/detection/networks/retinanet_network.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def __init__(
8888

8989
for layer in self.conv.children():
9090
if isinstance(layer, conv_type): # type: ignore
91-
torch.nn.init.normal_(layer.weight, std=0.01) # type: ignore
92-
torch.nn.init.constant_(layer.bias, 0) # type: ignore
91+
torch.nn.init.normal_(layer.weight, std=0.01)
92+
torch.nn.init.constant_(layer.bias, 0)
9393

9494
self.cls_logits = conv_type(in_channels, num_anchors * num_classes, kernel_size=3, stride=1, padding=1)
9595
torch.nn.init.normal_(self.cls_logits.weight, std=0.01)
@@ -167,8 +167,8 @@ def __init__(self, in_channels: int, num_anchors: int, spatial_dims: int):
167167

168168
for layer in self.conv.children():
169169
if isinstance(layer, conv_type): # type: ignore
170-
torch.nn.init.normal_(layer.weight, std=0.01) # type: ignore
171-
torch.nn.init.zeros_(layer.bias) # type: ignore
170+
torch.nn.init.normal_(layer.weight, std=0.01)
171+
torch.nn.init.zeros_(layer.bias)
172172

173173
def forward(self, x: list[Tensor]) -> list[Tensor]:
174174
"""
@@ -297,7 +297,7 @@ def __init__(
297297
)
298298
self.feature_extractor = feature_extractor
299299

300-
self.feature_map_channels: int = self.feature_extractor.out_channels # type: ignore[assignment]
300+
self.feature_map_channels: int = self.feature_extractor.out_channels
301301
self.num_anchors = num_anchors
302302
self.classification_head = RetinaNetClassificationHead(
303303
self.feature_map_channels, self.num_anchors, self.num_classes, spatial_dims=self.spatial_dims

monai/apps/reconstruction/networks/blocks/varnetblock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def soft_dc(self, x: Tensor, ref_kspace: Tensor, mask: Tensor) -> Tensor:
5555
Returns:
5656
Output of DC block with the same shape as x
5757
"""
58-
return torch.where(mask, x - ref_kspace, self.zeros) * self.dc_weight # type: ignore
58+
return torch.where(mask, x - ref_kspace, self.zeros) * self.dc_weight
5959

6060
def forward(self, current_kspace: Tensor, ref_kspace: Tensor, mask: Tensor, sens_maps: Tensor) -> Tensor:
6161
"""

monai/losses/cldice.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def soft_erode(img: torch.Tensor) -> torch.Tensor: # type: ignore
2929
if len(img.shape) == 4:
3030
p1 = -(F.max_pool2d(-img, (3, 1), (1, 1), (1, 0)))
3131
p2 = -(F.max_pool2d(-img, (1, 3), (1, 1), (0, 1)))
32-
return torch.min(p1, p2) # type: ignore
32+
return torch.min(p1, p2)
3333
elif len(img.shape) == 5:
3434
p1 = -(F.max_pool3d(-img, (3, 1, 1), (1, 1, 1), (1, 0, 0)))
3535
p2 = -(F.max_pool3d(-img, (1, 3, 1), (1, 1, 1), (0, 1, 0)))
3636
p3 = -(F.max_pool3d(-img, (1, 1, 3), (1, 1, 1), (0, 0, 1)))
37-
return torch.min(torch.min(p1, p2), p3) # type: ignore
37+
return torch.min(torch.min(p1, p2), p3)
3838

3939

4040
def soft_dilate(img: torch.Tensor) -> torch.Tensor: # type: ignore
@@ -48,9 +48,9 @@ def soft_dilate(img: torch.Tensor) -> torch.Tensor: # type: ignore
4848
https://github.com/jocpae/clDice/blob/master/cldice_loss/pytorch/soft_skeleton.py#L18
4949
"""
5050
if len(img.shape) == 4:
51-
return F.max_pool2d(img, (3, 3), (1, 1), (1, 1)) # type: ignore
51+
return F.max_pool2d(img, (3, 3), (1, 1), (1, 1))
5252
elif len(img.shape) == 5:
53-
return F.max_pool3d(img, (3, 3, 3), (1, 1, 1), (1, 1, 1)) # type: ignore
53+
return F.max_pool3d(img, (3, 3, 3), (1, 1, 1), (1, 1, 1))
5454

5555

5656
def soft_open(img: torch.Tensor) -> torch.Tensor:

monai/networks/blocks/feature_pyramid_network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ def __init__(
194194
conv_type_: type[nn.Module] = Conv[Conv.CONV, spatial_dims]
195195
for m in self.modules():
196196
if isinstance(m, conv_type_):
197-
nn.init.kaiming_uniform_(m.weight, a=1) # type: ignore
198-
nn.init.constant_(m.bias, 0.0) # type: ignore
197+
nn.init.kaiming_uniform_(m.weight, a=1)
198+
nn.init.constant_(m.bias, 0.0)
199199

200200
if extra_blocks is not None:
201201
if not isinstance(extra_blocks, ExtraFPNBlock):

monai/networks/nets/swin_unetr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def forward(self, x, mask):
519519
q = q * self.scale
520520
attn = q @ k.transpose(-2, -1)
521521
relative_position_bias = self.relative_position_bias_table[
522-
self.relative_position_index.clone()[:n, :n].reshape(-1) # type: ignore
522+
self.relative_position_index.clone()[:n, :n].reshape(-1)
523523
].reshape(n, n, -1)
524524
relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous()
525525
attn = attn + relative_position_bias.unsqueeze(0)
@@ -678,7 +678,7 @@ def load_from(self, weights, n_block, layer):
678678
self.norm1.weight.copy_(weights["state_dict"][root + block_names[0]])
679679
self.norm1.bias.copy_(weights["state_dict"][root + block_names[1]])
680680
self.attn.relative_position_bias_table.copy_(weights["state_dict"][root + block_names[2]])
681-
self.attn.relative_position_index.copy_(weights["state_dict"][root + block_names[3]]) # type: ignore
681+
self.attn.relative_position_index.copy_(weights["state_dict"][root + block_names[3]])
682682
self.attn.qkv.weight.copy_(weights["state_dict"][root + block_names[4]])
683683
self.attn.qkv.bias.copy_(weights["state_dict"][root + block_names[5]])
684684
self.attn.proj.weight.copy_(weights["state_dict"][root + block_names[6]])

monai/networks/nets/transchex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, *inputs, **kwargs) -> None:
4646

4747
def init_bert_weights(self, module):
4848
if isinstance(module, (nn.Linear, nn.Embedding)):
49-
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range) # type: ignore
49+
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
5050
elif isinstance(module, torch.nn.LayerNorm):
5151
module.bias.data.zero_()
5252
module.weight.data.fill_(1.0)

0 commit comments

Comments
 (0)