How do you determine the layer type?

Do you plan to treat Conv1d, Conv2d and so far as different? If you were only looking for Conv2d layers you can do something like:

for layer in net.children():
    if isinstance(layer, nn.Conv2d):
        do something with the layer

isinstance is a Python built-in https://docs.python.org/3/library/functions.html#isinstance

8 Likes