corenet icon indicating copy to clipboard operation
corenet copied to clipboard

'freeze_modules_based_on_opts()' is freezing module parameters twice

Open hub-bla opened this issue 10 months ago • 3 comments

Example

opts = argparse.Namespace(**{"model.freeze_modules": "conv1"})


model = nn.Sequential(
     OrderedDict([
          ('conv1', nn.Conv2d(20,64,5)),
          ('conv2', nn.Conv2d(20,64,5))
        ])
)


print(freeze_modules_based_on_opts(opts, model))

example_result

hub-bla avatar Apr 26 '24 17:04 hub-bla

Example

opts = argparse.Namespace(**{"model.freeze_modules": "conv1"})


model = nn.Sequential(
     OrderedDict([
          ('conv1', nn.Conv2d(20,64,5)),
          ('conv2', nn.Conv2d(20,64,5))
        ])
)


print(freeze_modules_based_on_opts(opts, model))

example_result

KRITSABIG avatar Apr 26 '24 19:04 KRITSABIG

Example

opts = argparse.Namespace(**{"model.freeze_modules": "conv1"})


model = nn.Sequential(
     OrderedDict([
          ('conv1', nn.Conv2d(20,64,5)),
          ('conv2', nn.Conv2d(20,64,5))
        ])
)


print(freeze_modules_based_on_opts(opts, model))

example_result

``mu

mustafahadbe avatar Apr 26 '24 23:04 mustafahadbe

GOT IT

Mandeep0001 avatar Apr 27 '24 16:04 Mandeep0001

Freezing modules (i.e. disabling .train()) is different with freezing parameters (i.e. setting requires_grad=False). As this issue is closely related to #10 , I'm closing this one.

mohammad7t avatar May 03 '24 17:05 mohammad7t