{"record":{"id":"87201a053e28e3d0","repo":"keras-team/keras","slug":"input-spatial-dimensions-must-be-statically-known","errorCode":null,"errorMessage":"Input spatial dimensions must be statically known for adaptive pooling","messagePattern":"Input spatial dimensions must be statically known for adaptive pooling","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/tensorflow/nn.py","lineNumber":428,"sourceCode":"    if data_format == \"channels_first\":\n        pooled_l = tf.transpose(pooled_l, (0, 2, 1))\n    return pooled_l\n\n\ndef _adaptive_average_pool2d(inputs, output_size, data_format=\"channels_first\"):\n    if isinstance(output_size, int):\n        output_size = (output_size, output_size)\n\n    if data_format == \"channels_first\":\n        inputs = tf.transpose(inputs, (0, 2, 3, 1))\n\n    static_shape = inputs.shape.as_list()\n    h_static = static_shape[1]\n    w_static = static_shape[2]\n    out_h, out_w = output_size\n\n    if h_static is None or w_static is None:\n        raise ValueError(\n            \"Input spatial dimensions must be \"\n            \"statically known for adaptive pooling\"\n        )\n\n    small_h, big_h = compute_adaptive_pooling_window_sizes(h_static, out_h)\n    small_w, big_w = compute_adaptive_pooling_window_sizes(w_static, out_w)\n\n    gather_h = _compute_static_gather_indices(h_static, out_h, small_h, big_h)\n    gather_w = _compute_static_gather_indices(w_static, out_w, small_w, big_w)\n\n    small_pool_h = tf.nn.pool(\n        inputs,\n        window_shape=(small_h, 1),\n        pooling_type=\"AVG\",\n        strides=(1, 1),\n        padding=\"VALID\",\n        data_format=\"NHWC\",\n    )","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/tensorflow/nn.py#L410-L446","documentation":"Error \"Input spatial dimensions must be statically known for adaptive pooling\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/tensorflow/nn.py:428 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":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}