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

Function verify_net_in_out

monai/bundle/scripts.py:1158–1256  ·  view source on GitHub ↗

Verify the input and output data shape and data type of network defined in the metadata. Will test with fake Tensor data according to the required data shape in `metadata`. Typical usage examples: .. code-block:: bash python -m monai.bundle verify_net_in_out network --met

(
    net_id: str | None = None,
    meta_file: str | Sequence[str] | None = None,
    config_file: str | Sequence[str] | None = None,
    device: str | None = None,
    p: int | None = None,
    n: int | None = None,
    any: int | None = None,
    extra_forward_args: dict | None = None,
    args_file: str | None = None,
    **override: Any,
)

Source from the content-addressed store, hash-verified

1156
1157
1158def verify_net_in_out(
1159 net_id: str | None = None,
1160 meta_file: str | Sequence[str] | None = None,
1161 config_file: str | Sequence[str] | None = None,
1162 device: str | None = None,
1163 p: int | None = None,
1164 n: int | None = None,
1165 any: int | None = None,
1166 extra_forward_args: dict | None = None,
1167 args_file: str | None = None,
1168 **override: Any,
1169) -> None:
1170 """
1171 Verify the input and output data shape and data type of network defined in the metadata.
1172 Will test with fake Tensor data according to the required data shape in `metadata`.
1173
1174 Typical usage examples:
1175
1176 .. code-block:: bash
1177
1178 python -m monai.bundle verify_net_in_out network --meta_file <meta path> --config_file <config path>
1179
1180 Args:
1181 net_id: ID name of the network component to verify, it must be `torch.nn.Module`.
1182 meta_file: filepath of the metadata file to get network args, if `None`, must be provided in `args_file`.
1183 if it is a list of file paths, the content of them will be merged.
1184 config_file: filepath of the config file to get network definition, if `None`, must be provided in `args_file`.
1185 if it is a list of file paths, the content of them will be merged.
1186 device: target device to run the network forward computation, if None, prefer to "cuda" if existing.
1187 p: power factor to generate fake data shape if dim of expected shape is "x**p", default to 1.
1188 n: multiply factor to generate fake data shape if dim of expected shape is "x*n", default to 1.
1189 any: specified size to generate fake data shape if dim of expected shape is "*", default to 1.
1190 extra_forward_args: a dictionary that contains other args for the forward function of the network.
1191 Default to an empty dictionary.
1192 args_file: a JSON or YAML file to provide default values for `net_id`, `meta_file`, `config_file`,
1193 `device`, `p`, `n`, `any`, and override pairs. so that the command line inputs can be simplified.
1194 override: id-value pairs to override or add the corresponding config content.
1195 e.g. ``--_meta#network_data_format#inputs#image#num_channels 3``.
1196
1197 """
1198
1199 _args = update_kwargs(
1200 args=args_file,
1201 net_id=net_id,
1202 meta_file=meta_file,
1203 config_file=config_file,
1204 device=device,
1205 p=p,
1206 n=n,
1207 any=any,
1208 extra_forward_args=extra_forward_args,
1209 **override,
1210 )
1211 _log_input_summary(tag="verify_net_in_out", args=_args)
1212 config_file_, meta_file_, net_id_, device_, p_, n_, any_, extra_forward_args_ = _pop_args(
1213 _args,
1214 "config_file",
1215 "meta_file",

Calls 10

read_configMethod · 0.95
read_metaMethod · 0.95
get_parsed_contentMethod · 0.95
ConfigParserClass · 0.90
update_kwargsFunction · 0.85
_log_input_summaryFunction · 0.85
_pop_argsFunction · 0.85
_get_net_io_infoFunction · 0.85
_get_fake_spatial_shapeFunction · 0.85
infoMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…