Why use np.asscalar nor item() to get scalar value?
ciuji opened this issue · comments
ciuji commented
in CH_4_Data_manipulation, we use
We can transform the result into a scalar in Python using the asscalar function of numpy. In the following example, the
$\ell_2$ norm of x yields a single element tensor. The final result is transformed into a scalar.
In[20]: np.asscalar(x.norm())
Out[20]: 22.494443893432617
Why don't just use x.norm().item()
to get the scalar, which seems much easier? Are their any differences?