Skip to content

AI Infrastructure

Equal Resized Shapes Can Contain Different Sample Values

Equal resized tensor shapes can contain different sampled values. For INTERP35's floating input [0,10,20] and explicit output length 5, PyTorch 2.14's one-dimensional linear definitions give ideal arrays [0,5,10,15,20] with align_corners=True and [0,4,10,16,20] with align_corners=False. Both have shape 1×1×5, endpoints 0 and 20, center value 10 and mean 10. Compare the required source-coordinate grid and the values at corresponding output positions before treating two preprocessing offers as equivalent.

Technical contentPublished Updated

01

Name the sample grid as well as the output size

A preprocessing offer that promises five output positions has specified a population. It also needs to explain where those positions sample the input. Linear interpolation combines neighboring values according to those source coordinates, so the coordinate convention contributes directly to the delivered numbers.

PyTorch 2.14's interpolate API supports linear mode on a three-dimensional tensor. Here its layout is N,C,L: batch items, channels and positions along one spatial axis. Three tensor dimensions therefore describe a one-dimensional sampling problem with batch and channel axes. Both offers below keep N and C equal to 1.

The align_corners argument distinguishes two grid relationships. True aligns the first and last input sample centers with the first and last output sample centers. False aligns the outer cell boundaries and uses edge values for positions beyond the input sample centers. The same output length can consequently select different interior source coordinates.

References: [P1] [P3]

02

INTERP35: three values and one linear mixing rule

INTERP35 is an original mathematical example. Stipulate one batch item and one channel with floating, unitless values [0,10,20], giving input shape 1×1×3. Place their sample centers at input coordinates 0, 1 and 2. These coordinates count sample-index intervals; no distance or time unit is stipulated.

Both definitions request the explicit output length 5, giving shape 1×1×5. No scale_factor argument is supplied. The only difference is the explicit alignment choice. There is no crop, anti-aliasing, integer conversion, quantization or other transformation. The scope is one-dimensional linear interpolation under the PyTorch 2.14 API and v2.14.0 tagged definitions. The calculations use exact ideal coordinates and arithmetic; they are not executed PyTorch results or promises of bitwise agreement across devices and dtypes.

For an interior source coordinate x between integer positions i and i+1, let t = x − i. Linear interpolation gives the earlier value weight 1 − t and the later value weight t. The result is (1 − t) × a_i + t × a_(i+1), where a_i is the supplied input value at position i. Changing x changes these weights even when the input values and output length stay fixed.

References: [P1] [P2] [P3]

03

True alignment divides the span between endpoint centers

Number the five output positions j = 0,1,2,3,4. With align_corners=True, the coordinate ratio is (input length − 1) / (output length − 1). INTERP35 therefore gives x(j) = j × (3 − 1) / (5 − 1) = j/2.

The source coordinates are [0,1/2,1,3/2,2]. The two input-index intervals between endpoint centers are divided into four equal intervals between output centers.

At output position 1, x = 1/2 lies halfway between input positions 0 and 1. Their values are 0 and 10, with weights 1/2 and 1/2. The ideal output is (1/2) × 0 + (1/2) × 10 = 5.

At output position 3, x = 3/2 lies halfway between input positions 1 and 2. Their values are 10 and 20, again with equal weights. The ideal output is (1/2) × 10 + (1/2) × 20 = 15.

Output positions 0, 2 and 4 fall directly on input sample centers. The complete ideal array is [0,5,10,15,20].

References: [P2]

04

False alignment divides the whole cell extent

With align_corners=False and no supplied scale_factor, the coordinate ratio is input length / output length = 3/5. The raw source coordinate is x(j) = (j + 1/2) × 3/5 − 1/2. For j from 0 through 4, this gives [−1/5,2/5,1,8/5,11/5].

The geometry can be read in the same input-index coordinates. Three unit-width input cells centered at 0, 1 and 2 occupy the extent from −1/2 to 5/2. Dividing that three-unit extent into five output cells gives width 3/5 per cell. Their centers are the raw coordinates above.

At output position 1, x = 2/5 lies between input positions 0 and 1. The earlier value has weight 3/5 and the later value has weight 2/5. The ideal output is (3/5) × 0 + (2/5) × 10 = 4.

At output position 3, x = 8/5 = 1 + 3/5 lies between input positions 1 and 2. The weights are 2/5 for value 10 and 3/5 for value 20. The ideal output is (2/5) × 10 + (3/5) × 20 = 16.

The first raw coordinate, −1/5, lies before the first sample center; the last, 11/5, lies after the last sample center. Edge-value padding supplies 0 and 20 at those positions. The center coordinate is exactly 1 and supplies 10. The complete ideal array is [0,4,10,16,20].

References: [P1] [P2]

05

The matching mean hides two changed positions

Both arrays contain five values and retain batch and channel dimensions, so both have shape 1×1×5. Both start at 0, end at 20 and contain 10 at output position 2. Checking only those three values would miss every changed position in this example.

The true-alignment sum is 0 + 5 + 10 + 15 + 20 = 50. The false-alignment sum is 0 + 4 + 10 + 16 + 20 = 50. Dividing either total by five gives mean 10.

Subtracting the true-alignment array from the false-alignment array gives [0,−1,0,+1,0]. The reduction of 1 at position 1 is canceled by the increase of 1 at position 3 when values are summed. A mean report discards that positional difference.

This matched sum is a property of INTERP35's symmetric example, not a general conservation rule for resizing arbitrary inputs. Here it establishes a precise limitation: shape, endpoints, center, sum and mean can all agree while the values at corresponding output positions differ.

06

Compare each offer with the receiving input's required grid

Suppose fictional Offer A declares INTERP35's true-alignment mapping and Offer B declares its false-alignment mapping. Both promise the same input values, linear interpolation and output length. Their descriptions still promise different sampled arrays.

If the receiving requirement names the grid x(j) = j/2, Offer A follows that mathematical requirement. Offer B supplies 4 rather than 5 at position 1 and 16 rather than 15 at position 3. Its matching shape and mean leave those differences unresolved.

If the requirement instead names five cell centers across the three-cell input extent, with the stated edge-value padding, Offer B follows that grid. The required interpretation of the samples decides the comparison. Neither boolean has a universal claim to better values or model quality.

Ask the appointed model or data-delivery owner to connect the supplied sample grid to the exact receiving input. The explanation should identify the input values and axis layout, operator and revision, explicit output size, alignment convention, boundary behavior and required output-coordinate grid. The proposal should also identify the implementation evidence supporting the required per-position values under the receiving owner's agreed numerical comparison criterion. Matching dimensions or an aggregate mean cannot supply that evidence.

07

Connect this value comparison to adjacent input questions

The related image resize-and-crop guide follows detection annotations into a transformed image's coordinate space. The ViT patch-grid guide follows image dimensions into encoder position counts. The convolution guide explains overlapping filter support and boundary features.

INTERP35 addresses the numerical values reconstructed from an unchanged supplied sample array. A complete AI input description may need several of these relationships, but annotation bounds, patch populations and convolution coefficients do not determine the interpolation coordinates derived here.

08

Discuss physical installation for separately selected equipment

If the selected AI equipment also needs receiving, rack integration, onsite installation or IT cabling, use the related Complete Physical Deployment service and project inquiry. Share a nonconfidential equipment list, site, required connections and physical handoff needs to discuss scope, requirements and availability.

Preprocessing definitions, model integration and acceptance of the sampled input remain with the appointed software and data owners. The physical inquiry concerns delivery and installation of the selected equipment.

References: [L1]

09Sources

Primary sources

  1. [P1]
    PyTorch 2.14 — torch.nn.functional.interpolateChecked 2026-10-21. Defines the input-axis interpretation, linear mode's three-dimensional input requirement, explicit output size, alignment conventions and edge-value padding applicable to this one-dimensional comparison.
  2. [P2]
    PyTorch v2.14.0 — resampling coordinate and neighboring-weight definitionsChecked 2026-10-21. The scale, source-coordinate and neighboring-weight definitions support INTERP35's two explicit-size derivations and their boundary treatment.
  3. [P3]
    PyTorch v2.14.0 — interpolate definition and one-dimensional linear pathChecked 2026-10-21. Confirms the named release's three-dimensional linear input path and the output-size and alignment parameters passed into that operation.
  4. [L1]
    Leviathan Systems — Complete Physical DeploymentChecked 2026-10-21. Describes a physical package covering equipment receiving, rack integration, onsite deployment, IT cabling and handoff, with project scope, requirements and availability confirmed separately.

Contact

Does the selected equipment need physical installation?

Share a nonconfidential equipment, site, connection and physical handoff outline to discuss installation scope, requirements and availability.