Tag: What Is Numpy Broadcasting ?


  • What Is Numpy Broadcasting ?

    What Is Numpy Broadcasting ?

    What Is Numpy Broadcasting ? Table Of Contents: What Is Broadcasting ? Examples Of Broadcasting. (1) What Is Broadcasting ? The term broadcasting describes how NumPy treats arrays with different shapes during arithmetic operations.  Subject to certain constraints, the smaller array is “broadcast” across the larger array so that they have compatible shapes. (2) Examples Of Broadcasting ? Example-1: import numpy as np data = np.array([1.0, 2.0]) data * 1.6 Output: array([1.6, 3.2]) Example-2: a = np.array([[ 0.0, 0.0, 0.0], [10.0, 10.0, 10.0], [20.0, 20.0, 20.0], [30.0, 30.0, 30.0]]) b = np.array([1.0, 2.0, 3.0]) a + b Output: array([[ 1.,

    Read More