{"record":{"id":"ce73739dc2ed7ff8","repo":"tensorflow/models","slug":"set-quantize-activations-called-on-layer-with","errorCode":null,"errorMessage":"`set_quantize_activations` called on layer {} with {} activation parameters, but layer expects {} values.","messagePattern":"`set_quantize_activations` called on layer (.+?) with (.+?) activation parameters, but layer expects (.+?) values\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/qat/nlp/quantization/configs.py","lineNumber":350,"sourceCode":"  def set_quantize_weights(self, layer, quantize_weights):\n    if len(self.weight_attrs) != len(quantize_weights):\n      raise ValueError(\n          '`set_quantize_weights` called on layer {} with {} '\n          'weight parameters, but layer expects {} values.'.format(\n              layer.name, len(quantize_weights), len(self.weight_attrs)))\n\n    for weight_attr, weight in zip(self.weight_attrs, quantize_weights):\n      current_weight = getattr(layer, weight_attr)\n      if current_weight.shape != weight.shape:\n        raise ValueError('Existing layer weight shape {} is incompatible with'\n                         'provided weight shape {}'.format(\n                             current_weight.shape, weight.shape))\n\n      setattr(layer, weight_attr, weight)\n\n  def set_quantize_activations(self, layer, quantize_activations):\n    if len(self.activation_attrs) != len(quantize_activations):\n      raise ValueError(\n          '`set_quantize_activations` called on layer {} with {} '\n          'activation parameters, but layer expects {} values.'.format(\n              layer.name, len(quantize_activations),\n              len(self.activation_attrs)))\n\n    for activation_attr, activation in zip(\n        self.activation_attrs, quantize_activations):\n      setattr(layer, activation_attr, activation)\n\n  def get_output_quantizers(self, layer):\n    if self.quantize_output:\n      return [self.activation_quantizer]\n    return []\n\n  @classmethod\n  def from_config(cls, config):\n    \"\"\"Instantiates a `Default8BitQuantizeConfig` from its config.\n","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/qat/nlp/quantization/configs.py#L332-L368","documentation":"Cardinality check in set_quantize_activations: the number of supplied quantize activation tensors must equal the number of activation attributes declared in activation_attrs; a mismatch raises this ValueError naming the layer and both counts.","triggerScenarios":"Thrown at official/projects/qat/nlp/quantization/configs.py:350 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure activation_attrs matches the activations tfmot collected for the layer","Check the QuantizeConfig is paired with the correct layer type","Update activation_attrs if the layer's activations changed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}