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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
139 | 어쩌다가.. | 우혜진 | 2000.09.28 | 2519 |
138 | 장문연습에 글 따로 제 메일로 보내 주세엽~! | ..... | 2000.09.27 | 2671 |
137 | 장문연습 따로 문장 파일로 올려 주세엽!! | ..... | 2000.09.27 | 2767 |
136 | Re: 조직 게시판 주소(링크법) | Ryan | 2000.09.27 | 2690 |
135 | Re: 승석아 나 세일이야.. | 한승석 | 2000.09.26 | 2386 |
134 | 승석아 나 세일이야.. | 손세일 | 2000.09.26 | 2533 |
133 | 조직 게시판 주소(링크법) | 한승석 | 2000.09.26 | 2581 |
132 | 하이!! | 현정 | 2000.09.26 | 2561 |
131 | 윽 못찾겠다. 어디냐? | 석원 | 2000.09.25 | 2627 |
130 | 승석 편지 고마워.. | 석원 | 2000.09.25 | 2683 |
129 | [공지] 조직 게시판 링크 | 한승석 | 2000.09.22 | 2819 |
128 | 에궁 | 최평균 | 2000.09.21 | 2359 |
127 | 컴퓨터 프로그래밍을 배우고 싶나요?? | 한승석 | 2000.09.20 | 2335 |
126 | 몸 튼튼 | 석원 | 2000.09.20 | 2633 |
125 | Re: 승석 생각 -별- | 석원 | 2000.09.20 | 2273 |
https://discuss.pytorch.org/t/combining-trained-models-in-pytorch/28383/2