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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
1686 | 나야~ 혜진... 오랜만인걸.. | 김혜진 | 2000.06.22 | 3381 |
1685 | 홈페이지 넘 멋있어요~ | 한양의대본4 | 2000.06.24 | 3316 |
1684 | 승석아 | 김재호 | 2000.06.27 | 3361 |
1683 | 앗 다시보니..새로운 문제점들이 | 김재호 | 2000.06.27 | 3311 |
1682 | Re: 앗 다시보니..새로운 문제점들이 | 한승석 | 2000.06.27 | 3621 |
1681 | Re: 승석아 | 한승석 | 2000.06.27 | 3302 |
1680 | 들어와본 소감 ...이거 대회에 도움되려나? | 강승민 | 2000.06.27 | 3160 |
1679 | 사진들이 업데이트 되었습니다. | 한승석 | 2000.06.28 | 3206 |
1678 | 승석아 홈페이지 참 멋있다. | 정석원 | 2000.07.03 | 3638 |
1677 | 버전은 어떻게 높이나요? | 박병선 | 2000.07.04 | 3361 |
1676 | 소스를 고쳐보세요. | 한승석 | 2000.07.05 | 3573 |
1675 | 사진 더 추가해줘잉 | 재호 | 2000.07.07 | 3608 |
1674 | 홈페이지가 너무 멋있군요, | kraye | 2000.07.10 | 3343 |
1673 | .승무. | 나비가루 | 2000.07.10 | 3476 |
1672 | 음란전화.... | 윤재원 | 2000.07.10 | 3648 |
https://discuss.pytorch.org/t/combining-trained-models-in-pytorch/28383/2