serhii.net

In the middle of the desert you can say anything you want

02 Dec 2019

Day 336

Tensorflow custom metrics return

Keras custom metrics raises error when update_state returns an op. · Issue #30711 · tensorflow/tensorflow · GitHub - forget about returning ops in custom metrics, internal Google TPU issue thing. It’s supposed not to work. Error was:

TypeError: To be compatible with tf.contrib.eager.defun, Python functions must return zero or more Tensors; in compilation of <function Function._defun_with_scope..wrapped_fn at 0xb34ec5d08>, found return value of type <class ’tensorflow.python.framework.ops.Operation’>, which is not a Tensor.

Tensorflow documentation

tf.assign_add - TensorFlow Python - W3cubDocs - is this another place to read readable TF documentation?

Tensorflow eager execution – again; this time with Intellij idea breakpoints

model.run_eagerly=True is not enough – when creating a custom Metric, as mentioned in metrics.py, tf.config.experimental_run_functions_eagerly(True) is also needed.

As added bonus - if this is not enabled, Intellij Idea debugging also doesn’t work. As in the breakpoints get ignored.

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus