@ ptrblck, I have tried another demo and the error mentioned above occurs!
As the result in my codas, the weights in model_se_dict are not changed when epoch>0. However, the parameters of model_se.state_dict()[‘feature_ensemble.0.0.weight’] change every time when I assign weights to the other layer!
import pandas as pd
import numpy as np
import random
import scipy.io
import os
from copy import deepcopy
#gridsearch/randomsearch
from itertools import product
from tqdm import tqdm

#visualize results
import matplotlib.pyplot as plt
import time

import torch
import torchvision
from torch import nn
from torch.autograd import Variable
from torch.utils.data import Subset,DataLoader,TensorDataset
from torchvision import datasets,transforms
import torch.nn.functional as F

#resnet18, using as the backbone
from torchvision.models import resnet18

def set_seed(seed):
    np.random.seed(seed)
    torch.manual_seed(seed)
    random.seed(seed)

    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False

# import warnings
# warnings.filterwarnings("ignore")

if torch.cuda.is_available():
    n_gpu = torch.cuda.device_count()
    print(f'number of gpu: {n_gpu}')
    print(f'cuda name: {torch.cuda.get_device_name(0)}')
  
    is_cuda=True
    print('GPU is on')
else:
    is_cuda=False
    print('GPU is off')

class unet_ensemble(nn.Module):
    def __init__(self, base_model, ensemble_num:int): 
        super(unet_ensemble,self).__init__()
        
        #ensemble number
        self.ensemble_num = ensemble_num
        
        #nn.modulelist
        self.feature_ensemble = nn.ModuleList([base_model for _ in range(self.ensemble_num)])
    
    def forward(self,X):
        pass

saved_name = 'model_base'
seed = 42

#save base model
for i in range(5):
    set_seed(i)
    model = resnet18(pretrained=False)
    model.add_module('fc',nn.Linear(512,1))
    
    torch.nn.init.xavier_uniform_(model.conv1.weight)
    torch.save(nn.Sequential(*list(model.children())[:-1]),  os.path.join('./', saved_name + '_epoch_'+ str(i) + '.pth'))

#selected epochs for ensembling
# epochs_select = np.arange(epochs)
epochs_select = np.arange(5)

#self-ensembled model
set_seed(seed)
base_model = resnet18(pretrained=False)
base_model = nn.Sequential(*list(base_model.children())[:-1])

if is_cuda:
    base_model.cuda()

#ensemble model
set_seed(seed)
model_se = unet_ensemble(base_model=base_model, ensemble_num=len(epochs_select)) #initialization

if is_cuda:
    model_se.cuda()

model_se_dict = model_se.state_dict()

#loaded pretrained model parameters for each epoch
for i,epoch in enumerate(tqdm(epochs_select)):
    loaded_dict = {}
    loaded_dict_epoch = torch.load(os.path.join('./', saved_name + '_epoch_'+ str(epoch) + '.pth'))

    for k,v in loaded_dict_epoch.state_dict().items():
        loaded_dict['feature_ensemble.' + str(epoch) + '.' + k] = v

    # 1. filter out unnecessary keys
    loaded_dict = {k: v for k, v in loaded_dict.items() if k in model_se_dict}

    # 2. overwrite entries in the existing state dict
    print(f"orignal model_se_dict: {model_se_dict['feature_ensemble.0.0.weight'][:2,0,0,0]}")
    model_se_dict.update(loaded_dict)
    
    # # 3. load the new state dict
    model_se.load_state_dict(model_se_dict,strict=True)
    
    print(f"updated model_se_dict: {model_se_dict['feature_ensemble.0.0.weight'][:2,0,0,0]}")
    print(f"updated model_se weights: {model_se.state_dict()['feature_ensemble.0.0.weight'][:2,0,0,0]}")
    print('\n')