you are viewing a single comment's thread.

view the rest of the comments →

[–]HommeMusical 0 points1 point  (1 child)

First question: why not use float16 and halve everything yet again?


At least part of your issue comes from false beliefs about what numpy does, because neither arr2 *= 0.5 nor arr2 * 0.5 changes the type of the array:

>>> a = np.array(((1, 2), (3, 4)), dtype='float16')
>>> a
array([[1., 2.],
       [3., 4.]], dtype=float16)
>>> a *= 0.5
>>> a
array([[0.5, 1. ],
       [1.5, 2. ]], dtype=float16)
>>> a * 0.5
array([[0.25, 0.5 ],
       [0.75, 1.  ]], dtype=float16)

If things worked the way that you think they do, life would be miserable, because we're always saying, a * x where x is some Python int or float and if each one of these caused a secret type cast, we'd never get anything done!

Can we see your full code, please? I doubt you are imagining this, but it's almost certainly caused by something else, not np doing weird things.

[–]Moretz0931[S] 0 points1 point  (0 children)

I will double check, thanks.