Skip to content

Crashed if using different types of grad in adadelta optimizer #55285

@GundamBen

Description

@GundamBen

I'm trying to use adadelta optimizer in my training process but it crashed. It came to that I used different types of value in grad parameters.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.8.0
  • Python version: 3.7.11

Describe the current behavior

Crashed with error info.

Describe the expected behavior

Error info could show the wrong type and would not crash.

Standalone code to reproduce the issue

from tensorflow.python.eager import context
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import variables
from tensorflow.python.training import adadelta


if __name__ == "__main__":
    num_updates = 4
    for grad in [0.2, 0.1, 0.01]:
      for lr in [1.0, 0.5, 0.1]:
          var0_init = [1.0, 2.0]
          var1_init = [3.0, 4.0]
          var0 = variables.Variable(var0_init, dtype=dtypes.float32)
          var1 = variables.Variable(var1_init, dtype=dtypes.float32)
          grads = constant_op.constant([grad, grad], dtype=dtypes.float16) # will pass if use dtypes.float32
          accum = 0.0
          accum_update = 0.0
          rho = 0.95
          epsilon = 1e-08

          adadelta_opt = adadelta.AdadeltaOptimizer(learning_rate=lr, rho=rho, epsilon=epsilon)
          if (not context.executing_eagerly()):
              adadelta_update = adadelta_opt.apply_gradients(zip([grads, grads], [var0, var1]))

              slot = ([None] * 2)
              slot_update = ([None] * 2)

          for step in range(num_updates):
              adadelta_opt.apply_gradients(zip([grads, grads], [var0, var1]))

Other info / logs Include any logs or source code that would be helpful to

2022-03-19 05:46:32.562381: F tensorflow/core/framework/tensor.cc:718] Check failed: dtype() == expected_dtype (1 vs. 19) half expected, got float

Aborted (core dumped)

Metadata

Metadata

Labels

TF 2.8comp:coreissues related to core part of tensorflowstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:bugBug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions