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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
1699 | MedicalPhoto 1.0.4 | WHRIA | 2008.05.12 | 7975 |
1698 |
Illustration
![]() | WHRIA | 2007.08.15 | 7973 |
1697 | Medicalphoto 1.08 | WHRIA | 2012.04.04 | 7963 |
1696 | 길드 마크 | WHRIA | 2009.11.02 | 7960 |
1695 | Fedora 6로 업그레이드 | WHRIA | 2007.09.25 | 7958 |
1694 | Fedora 7 (Reach Higher) 으로 update 중 [1] | WHRIA | 2007.09.28 | 7937 |
1693 | 도메인 구입 / gomphoto.com | WHRIA | 2013.01.12 | 7901 |
1692 | 차트 php | WHRIA | 2012.04.24 | 7891 |
1691 |
My dream car
[1] ![]() | WHRIA | 2007.09.25 | 7869 |
1690 | 구글 광고 코드 | WHRIA | 2009.01.18 | 7839 |
1689 | easybcd 멀티부팅 관리 프로그램 | WHRIA | 2012.02.05 | 7821 |
1688 | 골프 | WHRIA | 2008.10.02 | 7820 |
1687 | unicode | WHRIA | 2008.02.22 | 7813 |
1686 | 몇가지 사회현상 | WHRIA | 2009.09.14 | 7802 |
1685 | 윈도우 readyboost 기능도 쓸만하네 | WHRIA | 2012.12.10 | 7793 |
https://discuss.pytorch.org/t/combining-trained-models-in-pytorch/28383/2