MCPcopy
hub / github.com/facebookresearch/mmf / __init__

Method __init__

pythia/modules/encoders.py:32–50  ·  view source on GitHub ↗
(self, in_dim, weights_file, bias_file, model_data_dir)

Source from the content-addressed store, hash-verified

30
31class FinetuneFasterRcnnFpnFc7(nn.Module):
32 def __init__(self, in_dim, weights_file, bias_file, model_data_dir):
33 super(FinetuneFasterRcnnFpnFc7, self).__init__()
34 pythia_root = get_pythia_root()
35 model_data_dir = os.path.join(pythia_root, model_data_dir)
36
37 if not os.path.isabs(weights_file):
38 weights_file = os.path.join(model_data_dir, weights_file)
39 if not os.path.isabs(bias_file):
40 bias_file = os.path.join(model_data_dir, bias_file)
41 with open(weights_file, "rb") as w:
42 weights = pickle.load(w)
43 with open(bias_file, "rb") as b:
44 bias = pickle.load(b)
45 out_dim = bias.shape[0]
46
47 self.lc = nn.Linear(in_dim, out_dim)
48 self.lc.weight.data.copy_(torch.from_numpy(weights))
49 self.lc.bias.data.copy_(torch.from_numpy(bias))
50 self.out_dim = out_dim
51
52 def forward(self, image):
53 i2 = self.lc(image)

Callers

nothing calls this directly

Calls 3

get_pythia_rootFunction · 0.90
__init__Method · 0.45
loadMethod · 0.45

Tested by

no test coverage detected