class_docstr: Tests different learning rate schedules .
class_docstr_tok: ["Tests","different","learning","rate","schedules","."]
docstr: Test exponential schedule works correctly.
docstr_tok: ["Test","exponential","schedule","works","correctly","."]
code: def test_exponential_decay(self):
      """Test exponential schedule works correctly."""
      for test_params in [
          {"decay_steps": 200, "decay_rate": 0.99, "staircase": True},
          {"decay_steps": 200, "decay_rate": 0.99, "staircase": False},
      ]:
          config = ml_collections.ConfigDict(
              dict(
                  lr_configs={
                      "learning_rate_schedule": "compound",
                      "factors": "constant*exponential_decay",
                      "base_learning_rate": 0.1,
                      "decay_steps": test_params["decay_steps"],
                      "decay_rate": test_params["decay_rate"],
                      "staircase": test_params["staircase"],
                  }
              )
          )
          lr_fn = lr_schedules.get_learning_rate_fn(config)
          config = config.lr_configs
          tf_exponential_decay = (
              tf.keras.optimizers.schedules.ExponentialDecay(
                  initial_learning_rate=config["base_learning_rate"],
                  decay_steps=config["decay_steps"],
                  decay_rate=config["decay_rate"],
                  staircase=config["staircase"],
              )
          )
          for step in range(400):
              expected_learning_rate = tf_exponential_decay(
                  step=step
              ).numpy()
              self.assertAlmostEqual(
                  lr_fn(step), expected_learning_rate
              )
  
file_path: scenic/scenic/train_lib/tests/test_lr_schedules.py
imports: from absl.testing import absltest
  import ml_collections
  from scenic.train_lib import lr_schedules
  import tensorflow
label_desc: Use image node_id 4 for calling the LearningRateScchedulesTest obj's underlying member method code with example usage: obj.test_exponential_decay() without return types