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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
171 | Transformer | WHRIA | 2020.10.09 | 155 |
170 | stuff [2] | WHRIA | 2019.07.15 | 151 |
169 | pytorch pretrained | WHRIA | 2020.10.28 | 150 |
168 | 진료실 녹음 스크립트 | WHRIA | 2015.12.02 | 149 |
» | concat network [3] | WHRIA | 2020.08.27 | 147 |
166 | yolo custom | WHRIA | 2019.07.25 | 147 |
165 | delayed network drive connect | WHRIA | 2018.10.07 | 145 |
164 | 페이닥터 등록 | WHRIA | 2014.10.21 | 145 |
163 | SAS controller SAS 9212-4i | WHRIA | 2019.12.08 | 143 |
162 | pROC package [3] | WHRIA | 2019.05.11 | 143 |
161 | model split [1] | WHRIA | 2020.07.30 | 142 |
160 | Micro- and macro-averages | WHRIA | 2019.11.28 | 140 |
159 | 이궁 | WHRIA | 2019.03.12 | 139 |
158 | kakao | WHRIA | 2018.02.25 | 139 |
157 | 모든 code 를 python3 로 migration 중 | WHRIA | 2019.06.08 | 138 |
https://discuss.pytorch.org/t/combining-trained-models-in-pytorch/28383/2