Previous implementation cannot process the following code:
import torch.nn as nn
from bdpy.dl.torch.models import _parse_layer_name
model = nn.Sequential(
nn.Conv2d(3, 3, 3),
nn.ReLU(),
)
_parse_layer_name(model, "[0]")
# ValueError: Invalid layer name: '[0]'. Either the syntax of '[0]' is not supported, or Sequential object has no attribute '[0]'.
model[0] returns Conv2d instance so we would expect the above code should work.
This is because _parse_layer_name() does not assume the direct submodule access using index slicing. We have updated the behavior of the _parse_layer_name() so that it can take them.
Previous implementation cannot process the following code:
model[0]
returnsConv2d
instance so we would expect the above code should work.This is because
_parse_layer_name()
does not assume the direct submodule access using index slicing. We have updated the behavior of the_parse_layer_name()
so that it can take them.