0

Is there a way to load two trained models then give the output of the first one two the second and save this process as a new model in Tensorflow ? I can do that during inference by loading two different graphs and defining two sessions. But what I want is to create a third model which will take the input pass it thorough the first one then feed the output to the second and get the output. Something like the picture below. Model 1 and Model 2 are Pretrained.

Example

D_negn
  • 378
  • 4
  • 13

2 Answers2

0

I found the following gist combining multiple graphs through horizontal (what you want) and vertical stacking. This solution however still loads and saves to model1 and model2 files.
What you could try is loading from both models like in the example, but define a separate saver for the whole model (like you would do for a normal model as well).
Now you can load and save the combined model as one.
Have a look here for saving/loading

clotodex
  • 193
  • 2
  • 10
0

I don't think you can merge these models as such. But you can make a 3 model with the architecture of model 1 and model 2. Then you train the 3 model and save it. If you do not want to do that you can look into Ensemble models

mohsinali
  • 286
  • 1
  • 9