Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to merge multiple TensorFlow graphs into one?

I have two models trained with Tensorflow Python, exported to binary files named export1.meta and export2.meta. Both files will generate only one output when feeding with input, say output1 and output2.

My question is if it is possible to merge two graphs into one big graph so that it will generate output1 and output2 together in one execution.

Any comment will be helpful. Thanks in advance!

like image 319
yuan0122 Avatar asked Dec 28 '16 23:12

yuan0122


1 Answers

I kicked this around with my local TF expert, and the brief answer is "no"; TF doesn't have a built-in facility for this. However, you could write custom endpoint layers (input and output) with synch operations from Python's process management, so that they'd maintain parallel processing of each input, and concatenate the outputs.

Rationale

I like the way this could be used to get greater accuracy with multiple features, where the features have little or no correlation. For instance, you could train two character recognition models: one to identify the digit, the other to discriminate between left- and right-handed writers.

This would also allow you to examine the internal kernels that evolved for each individual feature, without interdependence with other features: the double-loop of an '8' vs the general slant of right-handed writing.

I also expect that the models for individual features will converge measurably faster than one over-arching training session.

Finally, it's quite possible that the individual models could be used in mix-and-match feature sets. For instance, train another model to differentiate letters, while letting your previously-trained left/right flagger would still have a pretty good guess at the writer's moiety.

like image 119
Prune Avatar answered Nov 06 '22 19:11

Prune