How to implying bagging method for LSTM neural network using pyTorch?
Like the title, my question is how to apply the Bagging method for LSTM using the PyTorch library? I have built one using TensorFlow on python. But now to implied into the system using C and C++, the requirement is I need to using PyTorch?

Is there any recommendation for not need to use the PyTorch and applying directly the model built on tensorflow into real predicting in the system??

Please help!

If you want to create an ensemble in PyTorch, you can train multiple models separately and then define a class to use them together:

class MyEnsemble(nn.Module):
    def __init__(self, firstModel, secondModel):
        super(MyEnsemble, self).__init__()
        self.firstModel = modelA
        self.secondModel = modelB
        self.classifier = nn.Linear(in_features, n_classes) #define accordingly
        self.relu = nn.ReLU()

    def forward(self, x1, x2):
        x1 = self.firstModel(x1)
        x2 = self.secondModel(x2)
        x = torch.cat((x1, x2), dim=1)
        x = self.classifier(self.relu(x))
        return x


If you want to use your TensorFlow model, there are multiple ways of doing so. One can export it to C++ Tensorflow -> C++
