# merge two neural networks at test time [closed]

I am currently using one network which gives me a bad resolution result, so then I use another network to enhance the resolution of my output. My question is: is there an easy way to use both of them at test time? I mean, I can train them separately and ok, but once I have the weights, how can I "merge" the execution of the two of them? I never wrote a script that uses two different neural networks.

For now they are both in separate project folders.

UPDATE: By merging I mean just using them sequentially. Cause this needs to be an automatic pipeline used by non-computer scientists. So I guess I don't need to merge the architectures. I am not really confident in python so I wanted to understand, is it possible to write a script that runs both of the networks? In that case, there would be a problem of compatibility of the different libraries versions the two networks are using. This is why I am asking. Or do you know any other better method to develop a pipeline that uses both of them without libraries conflicts?

• It depends on what you mean by "merge." Can you clarify what that means? Do you want to aggregate the predictions, or somehow combine the weights or layers of the models? Or something else? – Sycorax Oct 19 at 15:40
• What do you mean by "enhancing the resolution"? If I understand you correctly, you take the outputs of first network and use as input in second one. If that is the case, what is the problem with doing the same at inference time? – Tim Oct 19 at 15:40

As stated in the comment, same as during training you take outputs of first network as inputs to second one, during inference time you could do the same. This is simple function composition, if you treat the two networks as functions $$f$$ and $$g$$, and your output is $$g(f(x)) = y$$ then they form a composition $$(f \circ g)(x) = y$$. You don't need any fancy math for that, just take the inputs of first one and pass to the second one.