tensorflow / tensor2tensor

Library of deep learning models and datasets designed to make deep learning more accessible and accelerate ML research.
Apache License 2.0
15.5k stars 3.49k forks source link

Can one register callback functions for certain events (e.g. after eval)? #1142

Closed stefan-falk closed 6 years ago

stefan-falk commented 6 years ago

In T2TModel there is

# Replace the two methods below in order to add custom SessionRunHooks to
# the training procedure.
@staticmethod
def train_hooks():
  return []

@staticmethod
def eval_hooks():
  return []

However, the problem is that these hooks are already living in a session.

I want to quantize a graph after it has been evaluated in order to re-evaluate the quantized version of that graph. For this I need to slightly modify the original graph which means I have to create another session which is why SessionRunHooks are not the way to go here since their callbacks are always within a session context.

So is there a clean way to register a callback in the t2t-trainer which gives me control after the model evaluation stage (or something like this)?

stefan-falk commented 6 years ago

See PR https://github.com/tensorflow/tensor2tensor/pull/1158