serving icon indicating copy to clipboard operation
serving copied to clipboard

Is it possible to return different layers from model?

Open EricCat opened this issue 9 years ago • 2 comments

Is there a (hack) way for return different layers result from serving?

For example: Module 2 cnn

  • If want to return F7 (4096 nodes), not the final layer F8 (1000 nodes), is it possible?
  • If want to return both F7 and Latent Layer(H), how to handle it?

Update: SavedModelBuilder has method add_meta_graph_and_variables, which use meta_graph_pb2, might be there are some way that using graph_pb2?

EricCat avatar Mar 01 '17 02:03 EricCat

Different layers can be easily retrieved if the activations have been collected and returned, e.g., end_points in inceptions models

net, end_points = inception.inception_v3(inputs, num_classes, is_training=False)
net7 = end_points["Mixed_7c"]

It could also be acquired by get_tensor_by_name with naming, for example,

prediction = sess.graph.get_tensor_by_name("InceptionV3/Logits/Predictions:0")

Then, multiple tensors can be appended to outputs in the model exporter

'outputs': exporter.generic_signature({
         'prediction': prediction,
         'net': net,
         'net7': net7
       })

moonite avatar Mar 02 '17 03:03 moonite

@moonite Great! It makes sense. Thanks!

EricCat avatar Mar 05 '17 12:03 EricCat