As given in tf.constant documentation:
value is a list, then the length of the list must be less than or equal to the number of elements implied by the
shape argument (if specified).
In your code, the
value is the returned array from
np.arange(12,153,3) containing 47 integers.
Now, when you specify
shape = [2,3], it implies that the length of the list you have provided as
value is 2x3 = 6 which is not true because the array generated by
np.arange(12,153,3) has the length = 47. In this case, you will get an error saying:
ValueError: Too many elements provided. Needed at most 6, but received 47
On the other hand, when you specify
shape = [8,2,3], it implies that the length of the list you have provided as
value is 8x2x3 = 48 which is also not true because the actual length is 47. It does not raise an error because the length of the list can be less than the number implied by the
shape argument as it says in the documentation:
In the case where the list length is less than the number of elements specified by shape, the last element in the list will be used to fill the remaining entries.
So, it is not possible to shape a sequence of 47 elements to [2,3]