Use the reshape method with -1
As per numpy documentation says "One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions."
By default when you do array operations with 1D array on ND arrays. The broadcasting rules states the 1D array must have the same lenght as the Nth array dimension (the last one). See the exemples below
For more info
https://numpy.org/doc/stable/reference/generated/numpy.reshape.html#numpy-reshape
https://numpy.org/doc/stable/user/basics.broadcasting.html#broadcasting