Repository navigation
Simplify model initialization for kws streaming tests - #3706
Conversation
|
You'll need to import this into a CL. Also in the future it would be better to separate "unbreak the build" changes from functional changes like this :-) |
Oh, darn! And hmm, even though the reason the build was broken in order to make the functional changes? |
Yes :-) Well basically you don't want there to be contention on the review. Other options would've been asking for review of the functional stuff before submitting the build-breaking thing (to ensure there wouldn't be contention) or including the functional changes in the original google3 CL (assuming they're testable there). |
6a1ec6a to
c896e48
Compare
GMNGeoffrey
left a comment
There was a problem hiding this comment.
Hmmm maybe someone with more TF Python experience could review here? It looks to me like you're modifying class properties in a few places in weird ways to me. Like are you modifying the name of the class itself?? And then as part of creating a module through a classmethod, modifying the class state. This all seems a bit wonky, as opposed to something more like
class KeywordSpottingModule(tf.Module):
def __init__(self, model):
self.m = model
self.input_shapes = [tensor.shape for tensor in model.inputs]
self.name = modelAlso please update the PR description.
Ugh github didn't like me changing the name and the base branch at the same time, I guess. Thanks for catching that.
This isn't actually TensorFlow specific, and We can get around this by either creating a variable self._modules = tf_test_utils.compile_tf_module(KeywordSpottingModule, exported_names=['predict'])
model = utils.get_model_with_default_params(FLAGS.model, MODE_ENUM_TO_MODE[FLAGS.mode])
self._input_shapes = [tensor.shape for tensor in model.inputs]That would slow down the tests, however. A fourth option would be for someone to dig into the python bindings to add non-function exported names and then propagate that change up through each of the My vote is with either a global variable or an attribute on the class. What do you think? |
GMNGeoffrey
left a comment
There was a problem hiding this comment.
Ok I still don't love this, but I don't really have better suggestions :-D
Also generalizes the input shape specification to allow external streaming to be easily enabled after a keras bug is fixed.
Also generalizes the input shape specification to allow external streaming to be easily enabled after a keras bug is fixed.