2

I have a model to detect upto 10 digits, and I am using the same architecture of graph to detect 4 alphabets. It means first model have 10 classes and second model have 4 classes. Unfortunately, I have used the same variable names while training. Now I am trying to make a code to use both the models to detect digits as well as alphabets as given in code.

  graph_1 = tf.Graph() 
  with graph_1.as_default() as g_1:
    ...graph_1 content.....

  graph_2 = tf.Graph() 
  with graph_2.as_default() as g_2:
    ...graph_2 content.....

  sess_1 = tf.InteractiveSession(graph = g_1)
  sess_1.as_default()
  ....restoring model....

  sess_2 = tf.InteractiveSession(graph = g_2)
  sess_2.as_default()
  ....restoring model....
  .
  .
  .
  sess_1.run(prob, feed_dict)        
  sess_2.run(prob, feed_dict)      

But now, I know this is not the correct way to approach. If someone knows, plz help me to arrange this code or share some helpful link. Thanks in advance.

Akhilesh
  • 1,024
  • 1
  • 9
  • 26
  • Here are few suggestions: 1) Use different variable scope for the different models. 2) You might need to reorganise your files. Specifically, create a train.py file for training the models . 3) Then use a single script that calls each model and run it. Combine those results as necessary 4) Check this link for similar answer: https://stackoverflow.com/questions/42426960/how-does-one-train-multiple-models-in-a-single-script-in-tensorflow-when-there-a – smile Oct 21 '17 at 12:45

0 Answers0