2

スタックされた自動エンコーダーまたは再帰ネットワークを構築したいと考えています。これらは、反復ごとに構造を変更できる動的ニューラル ネットワークを構築するために必要です。

たとえば、私は最初に訓練します

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.fc1 = nn.Linear(784,500)
        self.fc2 = nn.Linear(500,784)

    def forward(self, x):
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        return x

次は以前のfc1とfc2を使ってトレーニングしたい

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.fc1 = nn.Linear(784,500)
        self.fc3 = nn.Linear(500,10)        
        self.fc4 = nn.Linear(10,500)
        self.fc2 = nn.Linear(500,784)

    def forward(self, x):
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc3(x))
        x = F.relu(self.fc4(x))
        x = F.relu(self.fc2(x))
        return x

これらのネットワークを単一モデルで構築するにはどうすればよいですか?

4

1 に答える 1