Addons: CohenKappa reset_states distributed training setup errors.

Created on 26 Nov 2019  路  4Comments  路  Source: tensorflow/addons

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Google Colab
  • TensorFlow version and how it was installed (source or binary): 2.0.0
  • TensorFlow-Addons version and how it was installed (source or binary): 0.6.0
  • Python version: 3.6
  • Is GPU used? (yes/no): yes

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.

bug metrics

Most helpful comment

@Squadrick Sure will do.

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings