How weights are used for making prediction?

HI
how weights are used for prediction the only thing I see is whenever we need to predict we used model ypred_valid = torch.(model(valid_images)) where model is architecture of my NN.

for index,(valid_images,valid_labels) in enumerate(validation_loader):
    valid_images = valid_images.to(device)
    valid_labels = valid_labels.to(device).float()
    ypred_valid =  torch.sigmoid(model(valid_images))

Usually I have multiple weights for same model So how I need to combine different models weights with same model architecture.

Thanks.!!

Sorry, I am not able to understand your question, is your question on how to ensemble different models ?

Sorry!! let me rephrase it.

So basically I capture weights of last three epochs (epoch =8,9, and 10) for same model.
Now I want to predict my test data-set.

ypred_valid = torch.sigmoid(model(valid_images)) ## where weights of epoch 8 is used.
ypred_valid = torch.sigmoid(model(valid_images)) ## where weights of epoch 9 is used.
ypred_valid = torch.sigmoid(model(valid_images)) ## where weights of epoch 10 is used.

In all three of them my model is same but model.state_dict() is different(which refers to weights.)

Now, How I load my model which takes weights(model.state_dict().) of epoch 8,9 and 10.

Well why do something like this:


for epoch in range(total_epochs):
    current_model = train()
    ypred_valid = torch.sigmoid(model(valid_images))
    if epoch == 8 or epoch ==9 or epoch 10:
        print(ypred_valid)

Sorry, if this is not the solution you were looking for, but does this not solve your use case?