System information
Describe the bug
When using cohen kappa metric within the distribution strategy scope, reset_states throws the following errors:
UFuncTypeError Traceback (most recent call last)
<ipython-input-20-56dc62930e1d> in <module>()
38 train_accuracy.reset_states()
39 test_accuracy.reset_states()
---> 40 test_kappa.reset_states()
2 frames
/tensorflow-2.0.0/python3.6/tensorflow_core/python/distribute/values.py in assign(self, *args,
**kwargs)
1218 tensor = args[0]
1219 if self._aggregation == vs.VariableAggregation.SUM:
-> 1220 tensor *= 1. / len(self.devices)
1221 return control_flow_ops.group(tuple(
1222 _assign_on_device(v.device, v, tensor) for v in self._values))
UFuncTypeError: Cannot cast ufunc 'multiply' output from dtype('float64') to dtype('int32') with
casting rule 'same_kind'
Code to reproduce the issue
Colab notebook
attached.
cc: @AakashKumarNain
I have fixed it temporarily by changing the variables and weight matrix dtype to tf.float32. I think float should be the correct dtype for the weight matrix by default.
@n3011 Could you please make a PR with the fix?
@Squadrick Sure will do.
Most helpful comment
@Squadrick Sure will do.