MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/networks/nets/efficientnet.py:480–562  ·  view source on GitHub ↗

Generic wrapper around EfficientNet, used to initialize EfficientNet-B0 to EfficientNet-B7 models model_name is mandatory argument as there is no EfficientNetBN itself, it needs the N in [0, 1, 2, 3, 4, 5, 6, 7, 8] to be a model Args: model_name: name of

(
        self,
        model_name: str,
        pretrained: bool = True,
        progress: bool = True,
        spatial_dims: int = 2,
        in_channels: int = 3,
        num_classes: int = 1000,
        norm: str | tuple = ("batch", {"eps": 1e-3, "momentum": 0.01}),
        adv_prop: bool = False,
    )

Source from the content-addressed store, hash-verified

478class EfficientNetBN(EfficientNet):
479
480 def __init__(
481 self,
482 model_name: str,
483 pretrained: bool = True,
484 progress: bool = True,
485 spatial_dims: int = 2,
486 in_channels: int = 3,
487 num_classes: int = 1000,
488 norm: str | tuple = ("batch", {"eps": 1e-3, "momentum": 0.01}),
489 adv_prop: bool = False,
490 ) -> None:
491 """
492 Generic wrapper around EfficientNet, used to initialize EfficientNet-B0 to EfficientNet-B7 models
493 model_name is mandatory argument as there is no EfficientNetBN itself,
494 it needs the N in [0, 1, 2, 3, 4, 5, 6, 7, 8] to be a model
495
496 Args:
497 model_name: name of model to initialize, can be from [efficientnet-b0, ..., efficientnet-b8, efficientnet-l2].
498 pretrained: whether to initialize pretrained ImageNet weights, only available for spatial_dims=2 and batch
499 norm is used.
500 progress: whether to show download progress for pretrained weights download.
501 spatial_dims: number of spatial dimensions.
502 in_channels: number of input channels.
503 num_classes: number of output classes.
504 norm: feature normalization type and arguments.
505 adv_prop: whether to use weights trained with adversarial examples.
506 This argument only works when `pretrained` is `True`.
507
508 Examples::
509
510 # for pretrained spatial 2D ImageNet
511 >>> image_size = get_efficientnet_image_size("efficientnet-b0")
512 >>> inputs = torch.rand(1, 3, image_size, image_size)
513 >>> model = EfficientNetBN("efficientnet-b0", pretrained=True)
514 >>> model.eval()
515 >>> outputs = model(inputs)
516
517 # create spatial 2D
518 >>> model = EfficientNetBN("efficientnet-b0", spatial_dims=2)
519
520 # create spatial 3D
521 >>> model = EfficientNetBN("efficientnet-b0", spatial_dims=3)
522
523 # create EfficientNetB7 for spatial 2D
524 >>> model = EfficientNetBN("efficientnet-b7", spatial_dims=2)
525
526 """
527 # block args
528 blocks_args_str = [
529 "r1_k3_s11_e1_i32_o16_se0.25",
530 "r2_k3_s22_e6_i16_o24_se0.25",
531 "r2_k5_s22_e6_i24_o40_se0.25",
532 "r3_k3_s22_e6_i40_o80_se0.25",
533 "r3_k5_s11_e6_i80_o112_se0.25",
534 "r4_k5_s22_e6_i112_o192_se0.25",
535 "r1_k3_s11_e6_i192_o320_se0.25",
536 ]
537

Callers

nothing calls this directly

Calls 2

_load_state_dictFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected