{"record":{"id":"cd31fc5961a7cbbd","repo":"keras-team/keras","slug":"adaptive-average-pool-supports-only-1d-2d-3d-input-cd31fc","errorCode":null,"errorMessage":"adaptive_average_pool supports only 1D/2D/3D inputs","messagePattern":"adaptive_average_pool supports only 1D/2D/3D inputs","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/jax/ops/nn.py","lineNumber":684,"sourceCode":"    combined_w = jnp.concatenate([small_w_pool, big_w_pool], axis=3)\n    out = jnp.take(combined_w, gather_w, axis=3)\n\n    if data_format == \"channels_first\":\n        out = jnp.transpose(out, (0, 4, 1, 2, 3))\n\n    return out\n\n\ndef adaptive_average_pool(inputs, output_size, data_format=None):\n    data_format = standardize_data_format(data_format)\n    dims = inputs.ndim - 2\n    if dims == 1:\n        return _adaptive_average_pool1d(inputs, output_size, data_format)\n    if dims == 2:\n        return _adaptive_average_pool2d(inputs, output_size, data_format)\n    if dims == 3:\n        return _adaptive_average_pool3d(inputs, output_size, data_format)\n    raise ValueError(\"adaptive_average_pool supports only 1D/2D/3D inputs\")\n\n\ndef adaptive_max_pool(inputs, output_size, data_format=None):\n    data_format = standardize_data_format(data_format)\n    dims = inputs.ndim - 2\n    if dims == 1:\n        return _adaptive_max_pool1d(inputs, output_size, data_format)\n    if dims == 2:\n        return _adaptive_max_pool2d(inputs, output_size, data_format)\n    if dims == 3:\n        return _adaptive_max_pool3d(inputs, output_size, data_format)\n    raise ValueError(\"adaptive_max_pool supports only 1D/2D/3D inputs\")\n\n\ndef _convert_to_lax_conv_dimension_numbers(\n    num_spatial_dims,\n    data_format=\"channels_last\",\n    transpose=False,","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/jax/ops/nn.py#L666-L702","documentation":"Dispatch guard in the JAX backend's adaptive_average_pool: it computes the number of spatial dims as inputs.ndim - 2 and routes 1D/2D/3D cases to dedicated kernels. Any other rank (0D, 4D+, or inputs with fewer than 3 dims) falls through to this generic rejection. Note the message text says 'adaptive_average_pool' but it applies to the average variant.","triggerScenarios":"Thrown at keras/src/backend/jax/ops/nn.py:684 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reshape the input to rank 3 (1D: (batch, length, channels)), rank 4 (2D), or rank 5 (3D) depending on the pooling variant used","For higher-dimensional pooling, apply the op to a flattened spatial view or use regular (non-adaptive) pooling layer-by-layer","Verify data_format matches the actual layout so ndim is interpreted correctly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}