{"record":{"id":"2cbf1a455391f683","repo":"tensorflow/models","slug":"initializer-not-supported","errorCode":null,"errorMessage":"Initializer {} not supported","messagePattern":"Initializer (.+?) not supported","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/xlnet/xlnet_modeling.py","lineNumber":37,"sourceCode":"\nimport tensorflow as tf, tf_keras\nfrom official.legacy.xlnet import data_utils\nfrom official.nlp.modeling import networks\n\n\ndef gelu(x):\n  return tf_keras.activations.gelu(x, approximate=True)\n\n\ndef _get_initializer(flags):\n  \"\"\"Get variable initializer.\"\"\"\n  if flags.init_method == \"uniform\":\n    initializer = tf_keras.initializers.RandomUniform(\n        minval=-flags.init_range, maxval=flags.init_range)\n  elif flags.init_method == \"normal\":\n    initializer = tf_keras.initializers.RandomNormal(stddev=flags.init_std)\n  else:\n    raise ValueError(\"Initializer {} not supported\".format(flags.init_method))\n  return initializer\n\n\ndef rel_shift(x, klen=-1):\n  \"\"\"Performs relative shift to form the relative attention score.\"\"\"\n  x_size = tf.shape(x)\n\n  x = tf.reshape(x, [x_size[1], x_size[0], x_size[2], x_size[3]])\n  x = tf.slice(x, [1, 0, 0, 0], [-1, -1, -1, -1])\n  x = tf.reshape(x, [x_size[0], x_size[1] - 1, x_size[2], x_size[3]])\n  x = tf.slice(x, [0, 0, 0, 0], [-1, klen, -1, -1])\n\n  return x\n\n\ndef _create_mask(qlen, mlen, dtype=tf.float32, same_length=False):\n  \"\"\"Creates attention mask when single-side context allowed only.\"\"\"\n  attn_mask = tf.ones([qlen, qlen], dtype=dtype)","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/xlnet/xlnet_modeling.py#L19-L55","documentation":"Error \"Initializer {} not supported\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/xlnet/xlnet_modeling.py:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}