{"record":{"id":"ed7e8fc5a2a8de29","repo":"keras-team/keras","slug":"input-length-must-be-statically-known-for-adaptive","errorCode":null,"errorMessage":"Input length must be statically known for adaptive pooling","messagePattern":"Input length must be statically known for adaptive pooling","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/tensorflow/nn.py","lineNumber":340,"sourceCode":"    small_indices = window_starts\n    big_indices = window_starts + small_pool_len\n\n    gather_indices = tf.where(is_big_window, big_indices, small_indices)\n    return tf.cast(gather_indices, tf.int32)\n\n\ndef _adaptive_average_pool1d(inputs, output_size, data_format=\"channels_first\"):\n    if isinstance(output_size, int):\n        output_size = (output_size,)\n    if data_format == \"channels_first\":\n        inputs = tf.transpose(inputs, (0, 2, 1))\n\n    static_shape = inputs.shape.as_list()\n    l_static = static_shape[1]\n    out_l = output_size[0]\n\n    if l_static is None:\n        raise ValueError(\n            \"Input length must be statically known for adaptive pooling\"\n        )\n\n    small_l, big_l = compute_adaptive_pooling_window_sizes(l_static, out_l)\n    gather_l = _compute_static_gather_indices(l_static, out_l, small_l, big_l)\n\n    small_pool_l = tf.nn.pool(\n        inputs,\n        window_shape=(small_l,),\n        pooling_type=\"AVG\",\n        strides=(1,),\n        padding=\"VALID\",\n        data_format=\"NWC\",\n    )\n    big_pool_l = tf.nn.pool(\n        inputs,\n        window_shape=(big_l,),\n        pooling_type=\"AVG\",","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/tensorflow/nn.py#L322-L358","documentation":"Error \"Input length must be statically known for adaptive pooling\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/tensorflow/nn.py:340 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"}