我想要把两个模型结合起来 ,并计算两个模型合并后的auc、aupr等参数,目前已知一个模型计算相关参数的代码,请问我应该要如何修改才能使代码可以计算两个模型并行之后的相关参数?
valid_score, valid_label = [], [] ###
# combined_model = nn.Sequential(model2, model)
#combined_model.train
# 将组合模型设置为评估模式
model2.eval()
# model.eval()
with torch.no_grad():
# print("-----validing-----")
for i, item in enumerate(validLoader):
data, label = item
train_data = data.cuda()
pre_score = combined_model(simData, train_data)
# pre_score=combined_model(simData,train_data,features, adj_norm, adj_tensor, drug_nums)
batch_score = pre_score.cpu().detach().numpy()
valid_score = np.append(valid_score, batch_score)
valid_label = np.append(valid_label, label.numpy())
# torch.save(model.state_dict(), "./savemodel/fold_{}.pkl".format(a)) ###
metric = get_metrics(valid_score, valid_label)
valid_metric.append(metric)
已知两个模型分别为:
model = HOML(args, args.num_features, args.features_nonzero,
dropout=args.dropout,
bias=args.bias,
sparse=False)
model2 = AHD(EmbeddingM(param), EmbeddingD(param), MDI(param))
恳请各位帮忙解答!感谢!