concat network
2020.08.27 00:19
https://discuss.pytorch.org/t/concatenate-layer-output-with-additional-input-data/20462
댓글 3
-
WHRIA
2020.09.05 11:08
-
WHRIA
2020.09.05 11:17
class MyModelA(nn.Module): def __init__(self): super(MyModelA, self).__init__() self.fc1 = nn.Linear(10, 2) def forward(self, x): x = self.fc1(x) return x class MyModelB(nn.Module): def __init__(self): super(MyModelB, self).__init__() self.fc1 = nn.Linear(20, 2) def forward(self, x): x = self.fc1(x) return x class MyEnsemble(nn.Module): def __init__(self, modelA, modelB): super(MyEnsemble, self).__init__() self.modelA = modelA self.modelB = modelB self.classifier = nn.Linear(4, 2) def forward(self, x1, x2): x1 = self.modelA(x1) x2 = self.modelB(x2) x = torch.cat((x1, x2), dim=1) x = self.classifier(F.relu(x)) return x # Create models and load state_dicts modelA = MyModelA() modelB = MyModelB() # Load state dicts modelA.load_state_dict(torch.load(PATH)) modelB.load_state_dict(torch.load(PATH)) model = MyEnsemble(modelA, modelB) x1, x2 = torch.randn(1, 10), torch.randn(1, 20) output = model(x1, x2)
-
WHRIA
2020.10.08 13:08
https://gist.github.com/andrewjong/6b02ff237533b3b2c554701fb53d5c4d
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
274 | 페이닥터 등록 | WHRIA | 2014.10.21 | 173 |
273 | usb 3.1 + DP | WHRIA | 2020.01.07 | 172 |
» | concat network [3] | WHRIA | 2020.08.27 | 170 |
271 | resnest50 caffe | WHRIA | 2020.06.21 | 168 |
270 | pytorch pretrained | WHRIA | 2020.10.28 | 168 |
269 | pytorch optimize | WHRIA | 2020.08.01 | 167 |
268 | CORS | WHRIA | 2021.01.22 | 167 |
267 | 역시 개원해서는 돈 버는 재미밖에 없다. | WHRIA | 2016.06.17 | 164 |
266 | pROC package [3] | WHRIA | 2019.05.11 | 161 |
265 | Transformer | WHRIA | 2020.10.09 | 160 |
264 | yolo custom | WHRIA | 2019.07.25 | 159 |
263 | fast rcnn cudnn 5.0 | WHRIA | 2017.01.08 | 158 |
262 | SAS controller SAS 9212-4i | WHRIA | 2019.12.08 | 158 |
261 | file lock | WHRIA | 2020.09.22 | 158 |
260 | startup , 미국 | WHRIA | 2020.07.30 | 155 |
https://discuss.pytorch.org/t/combining-trained-models-in-pytorch/28383/2