Citation details
This text is extracted from a pre-print of the paper and may have errors.
This is the author's version of the paper and it may be annotated by the typist.
Vancouver:
Yamtal, yamtal:
pippi digitali avvoc
-30-cmcpsci.glu.ac.uk (2020-08-25)
[pre-print]
.
Q:
How to expand a tensor to two dimensions in Keras?
Suppose I have a tensor with three dimensions:
In [12]: x
Out[12]:
array([[[[ 1., 2., 3.]],
[[ 4., 5., 6.]],
[[ 7., 8., 9.]]]], dtype=float32)
How do I create a tensor that is two times longer in all three dimensions?
In [13]: x_expanded
Out[13]:
array([[[[ 1., 2., 3.],
[ 4., 5., 6.]],
[[ 7., 8., 9.],
[ 7., 8., 9.]],
[[ 9., 10., 11.],
[ 9., 10., 11.]]]], dtype=float32)
The tensor should have a shape of (3,2,2,2).
I tried to use the following, but it doesn't work.
In [13]: x_expanded = np.expand_dims(x, axis=-1)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
----> 1 x_expanded = np.expand_dims(x, axis=-1)
ValueError: NumPy boolean array indexing assignment requires an axis
A ac619d1d87
Related links:
Comments