Kumita← Open visual lesson

Keep the strongest response

The code behind the picture

Follow the lesson’s implementation, one code cell at a time.

Choose a language and read the cells in order. These are small teaching examples; the visual lesson runs separately.

Follow the calculation

Same inputs · Same operation · Same result

3 teaching cells · Python standard library · Read-only

  1. 1. Prepare the inputs

    One 2 × 2 region of the watermelon's feature map: four responses from the lesson.

    import json
    
    block = [[6, 16], [0, 11]]
  2. 2. Keep the local maximum

    A 2 × 2 pooling window contributes one value, its largest. Moving the maximum within this window preserves that value.

    result = max(value for row in block for value in row)
  3. 3. Inspect the result

    Print the result as JSON so both languages use the same output format.

    print(json.dumps(result))

Expected result

Running the three cells in order produces this result in either language.

16