What you have works to determine the size of fc, but your are not registering the Conv2ds as submodules. If you want to keep using a list container, please use ModuleList instead of []. Otherwise, you need to explicitly set the Conv2ds as submodules with setattr or add_module.