Class BroadcastMissingDimensionsStrategy

  • All Implemented Interfaces:
    ManipulationOption, Option<ManipulationOption>, BroadcastingStrategy

    public class BroadcastMissingDimensionsStrategy
    extends java.lang.Object
    implements BroadcastingStrategy
    A broadcasting strategies that broadcasts all dimensions which are not available in one tensor to the shape of the second tensor. For example, lets assume tensors of double values:
    • the left tensor has one dimension X with two entries {[x1]=1.0, [x2]=2.0},
    • the right tensor has one dimension Y with two entries {[y1]=0.1, [y2]=0.2},
    then these two tensors will both be broadcasted to tensors with two dimensions (X, Y) and four values:
    • broadcasted left: {[x1,y1]=1.0, [x1,y2]=1.0, [x2,y1]=2.0, [x2,y2]=2.0},
    • broadcasted left: {[x1,y1]=0.1, [x1,y2]=0.2, [x2,y1]=0.1, [x2,y2]=0.2}.
    This strategy is rather close to the behaviour of numpy, but has one very important difference: It does NOT broadcast dimensions with one entry. So, if e.g. in the following example, the second tensor would have had a different shape, like {[x1, y1]=1.0, [x2, y1]=2.0}, then it would have remained the same after broadcasting and the shapes of the two resulting tensors would be different. This still can be useful in calculations. The final shape for the result is determined from the two input shapes by a different strategy, the shaping strategy.

    The reason for this important difference to numpy, is that we consider this as more consistent in the general case: If a dimension is not present in a tensor, we treat it as 'applicable for all' while if the dimension is present with one entry, then it is clearly defined where the values are positioned in this dimension and it would be dangerous to assume they would be applicable everywhere.

    • Constructor Detail

      • BroadcastMissingDimensionsStrategy

        @Deprecated
        public BroadcastMissingDimensionsStrategy()
        Deprecated.
        use factory method get()