I know I can do np.subtract.outer(x, x)
. If x
has shape (n,)
, then I end up with an array with shape (n, n)
. However, I have an x
with shape (n, 3)
. I want to output something with shape (n, n, 3)
. How do I do this? Maybe np.einsum
?
相关问题
- Django __str__ returned non-string (type NoneType)
- How to postpone/defer the evaluation of f-strings?
- ImportError shows up with py.test, but not when ru
- Unable to load a previously dumped pickle file in
- Memory for python.exe on Windows 7 python 32 - Num
相关文章
- Airflow depends_on_past explanation
- Numpy matrix of coordinates
- Python has stopped working
- implementing R scale function in pandas in Python?
- Raspberry Pi-Python: Install Pandas on Python 3.5.
- Numpy array to TFrecord
- Is there a standard way to store XY data in python
- ValueError: Unknown label type: 'continuous
You can use
broadcasting
after extending the dimensions withNone
/np.newaxis
to form a 3D array version ofx
and subtracting the original 2D array version from it, like so -Sample run -