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
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
1549 | 아래 주소는 새 홈페이지 주소입니다. | 한승석 | 2002.06.19 | 2116 |
1548 | 여기는 집입니다~ | 한승석 | 2003.01.10 | 2097 |
1547 | 승석이가 피부과에 합격했답니다. | 한승석 | 2003.01.10 | 2314 |
1546 | 외로움 | 한승석 | 2003.01.27 | 2102 |
1545 | 홈페이지 배경음악을 넣었습니다. | 한승석 | 2003.01.27 | 2103 |
1544 | 오늘은 인턴 페어웰을 암센터에서~~ | 한승석 | 2003.01.29 | 2101 |
1543 | 멋진 걸! | 채영광 | 2003.01.29 | 2103 |
1542 | 자료실에 성소재림 , catch me if you can 등의 영화가 올렸습니다. | 한승석 | 2003.01.29 | 2088 |
1541 | 다시 제주도로.. | 한승석 | 2003.01.30 | 2114 |
1540 | 요즘 얼굴에 주름이 생겨서 고민.. | 한승석 | 2003.01.30 | 2087 |
1539 | 도전과 응전 | 한승석 | 2003.01.30 | 2020 |
1538 | 홈페이지 새단장 완료 | 한승석 | 2003.01.30 | 2090 |
1537 | 한라병원에 도착했습니다... | 한승석 | 2003.01.31 | 2079 |
1536 | 한라 병원 인근의 겜방 ^^ | 한승석 | 2003.01.31 | 2106 |
1535 | 이번 달은 한라병원 응급실에 근무 | 한승석 | 2003.01.31 | 2836 |
https://discuss.pytorch.org/t/combining-trained-models-in-pytorch/28383/2