1
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ 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? $\endgroup$ – Sycorax Oct 19 at 15:40
  • 2
    $\begingroup$ 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? $\endgroup$ – Tim Oct 19 at 15:40
1
$\begingroup$

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.

Said that, it can be the case, that if you had a single network, containing of both those networks, it would end up in different minimum, with different parameters, possibly better. This however would need you to re-train the network, find the new, optimum, hyperparameter set, validate it again etc. In such case, the output of the first network would be a latent variable, or just intermediate layer output, playing same role as output of any other layer of the network. Without any more details on your data and the architectures it is hard to give more details.

| cite | improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.