{"record":{"id":"374d134c84839c1b","repo":"google-research/timesfm","slug":"activation-config-activation-not-supported","errorCode":null,"errorMessage":"Activation: {config.activation} not supported.","messagePattern":"Activation: (.+?) not supported\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/timesfm/flax/dense.py","lineNumber":64,"sourceCode":"      in_features=config.hidden_dims,\n      out_features=config.output_dims,\n      use_bias=config.use_bias,\n      rngs=rngs,\n    )\n    self.residual_layer = nnx.Linear(\n      in_features=config.input_dims,\n      out_features=config.output_dims,\n      use_bias=config.use_bias,\n      rngs=rngs,\n    )\n    if config.activation == \"relu\":\n      self.activation = jax.nn.relu\n    elif config.activation == \"swish\":\n      self.activation = jax.nn.swish\n    elif config.activation == \"none\":\n      self.activation = lambda x: x\n    else:\n      raise ValueError(f\"Activation: {config.activation} not supported.\")\n\n  def __call__(self, x: Float[Array, \"b ... i\"]) -> Float[Array, \"b ... o\"]:\n    return self.output_layer(\n      self.activation(self.hidden_layer(x))\n    ) + self.residual_layer(x)\n\n\nclass RandomFourierFeatures(nnx.Module):\n  \"\"\"Random Fourier features layer.\"\"\"\n\n  __data__ = (\"phrase_shifts\",)\n\n  def __init__(self, config: RandomFourierFeaturesConfig, *, rngs=nnx.Rngs(42)):\n    self.config = config\n\n    if config.output_dims % 4 != 0:\n      raise ValueError(\n        f\"Output dims must be a multiple of 4: {config.output_dims} % 4 != 0.\"","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/google-research/timesfm/blob/331c6d33cb1ac2611de3056d0ac7164aab6301eb/src/timesfm/flax/dense.py#L46-L82","documentation":"The MLP block's __init__ only supports activation names 'relu', 'swish', and 'none' (mapping to jax.nn functions or identity). Any other config.activation string falls through to this ValueError. It is a config validation error raised at module construction time, before any forward pass.","triggerScenarios":"Constructing the MLP/dense module with a config whose activation field is set to an unsupported string such as 'gelu', 'tanh', 'ReLU', 'sigmoid', or a None/typo value instead of 'relu', 'swish', or 'none'.","commonSituations":"Copying a config from another framework (e.g. HF transformers uses 'gelu' by default), typos or casing mistakes in the activation name, or hand-editing a config dict to an activation the TimesFM flax backend does not implement.","solutions":["Set config.activation to one of the supported values: 'relu', 'swish', or 'none'.","If you need another activation, add an elif branch mapping it to the corresponding jax.nn function in dense.py.","Check for casing/typo issues ('relu' vs 'ReLU') in the config source (YAML/JSON/CLI flag)."],"exampleFix":"// before\nconfig = DenseConfig(activation=\"gelu\")  # ValueError\n// after\nconfig = DenseConfig(activation=\"relu\")  # or \"swish\" / \"none\"","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"relu\", \"swish\", \"none\"}\nif config.activation not in SUPPORTED:\n    raise ValueError(f\"activation must be one of {sorted(SUPPORTED)}, got {config.activation!r}\")","typeGuard":"def is_supported_activation(a: object) -> bool:\n    return isinstance(a, str) and a in {\"relu\", \"swish\", \"none\"}","tryCatchPattern":"try:\n    layer = DenseModule(config)\nexcept ValueError as e:\n    if \"not supported\" in str(e) and \"Activation\" in str(e):\n        config.activation = \"relu\"\n        layer = DenseModule(config)\n    else:\n        raise","preventionTips":["Keep activation strings lowercase and copied from the library's supported list.","Validate the entire config against a schema (pydantic/dataclass with Literal[\"relu\",\"swish\",\"none\"]) before constructing modules.","Add a unit test that constructs the module with each supported value."],"tags":["config","validation","jax","valueerror"],"backgroundTag":"unsupported-config-value","analyzedSha":"331c6d33cb1ac2611de3056d0ac7164aab6301eb","analyzedAt":"2026-08-29T01:04:23.138Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}