Closed shinianzhihou closed 3 years ago
Hi @shinianzhihou we don't have any plans currently of supporting pre-trained models. But if you have weights from any repository, you can easily write a script which maps the keys to the right format - this code would have to depend on the source implementation though. As a small example,
class TestModel1(nn.Module):
def __init__(self):
...
self.conv1 = nn.Conv2d(1, 2, 3)
class TestModel2(nn.Module):
def __init__(self):
...
self.c1 = nn.Conv2d(1, 2, 3)
To use the state dictionary from TestModel1
in TestModel2
, the "conv1"
key would have to be renamed to "c1"
. The easiest way to do this is to print the keys for both model states and look at the implementations to see which key maps to which in the two dicts.
Another option is to re-use the source implementation in Classy Vision - you can bring your own model in Classy Vision easily :) see https://classyvision.ai/tutorials/classy_model for examples
Thanks for your reply, I have solved this problem !
I'm trying to load the pre-trained model (efficientnet) for another repo but the keys doesn't match. Can you pls provide the pre-trained Efficientnet.torch or the trunk.pt ? or provide any ideas for this problem: