-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metrics does not work with tf.keras.estimator.model_to_estimator #39
Comments
I think I found the reason but I have no idea about how to fix it estimator.model_to_estimator will replace the graph built by keras with the graph they make, and the class is stateful, so an object, for example, built by true_positive, keeps an variant as self.tp, which is built by keras when I call it, but the graph of variant y_true/y_pred is replaced I am not sure why there is a stateful layer because I check all loss/metrics of keras, I haven't found any loss is relies on the state of object(i.e. they are stateless), but I am not sure how keras_metrics work... Could you please provide some advices @ybubnov ? |
Seems it is caused by the behaviour of when model_to_estimator process layer and metrics, it might replace the graph of any layer(I guess) but it will not replace the graph in metrics since they assumed that the metrics is STATLESS. As far as I concerned, true_positive is implemented as a layer will reduce the cost of calculation when user require multiple metrics provide by keras_metrics(? I am not sure, I had been confused by the calling chain). IF what I think is right, I think it is a meaningless optimization because it makes potential incompatibles. Sorry for my broken english and hope it helps |
I also faced a samliar issue; the Metrics does not work with tf.keras.estimator.model_to_estimator.
File "/Users/sangyongjia/anaconda3/envs/tf1.x/lib/python3.7/site-packages/tensorflow/python/keras/engine/training_utils.py", line 873, in call_metric_function the correspond code is : if I remove tf.keras.metrics.AUC() anyone has some great idea? thx in advance. |
@sangyongjia, it looks that your problem relates to TensorFlow project, not to the |
you mean I should remove the Tensorflow and install it again or update to higher version of tf ? |
@sangyongjia, it looks that the problem is in the I think one of possible ways to deal with the problem is to enforce issue resolution I've posted above. Alternatively, you could not use From my side, I'll try to relax the TensorFlow restriction in order to allow newer version of TensorFlow be used with |
thx so much @ybubnov |
I am trying to use
tf.keras.estimator.model_to_estimator
to convert tf.keras model to be distributed, however, I found that keras-metrics does not work as desired, Is there any idea or work around for me ? thanksTraceback:
Buggy code (a little bit messy...)
model.py.zip
If I dont add
keras_metrics.sparse_categorical_precision()
into Accuracy part, it DOES work but fail when I add sparse_categorical_precision...Tested in Py2.7/3.7 TF 1.13.1
The text was updated successfully, but these errors were encountered: