Discussion:
[Numpy-discussion] Flag for np.tile to use as_strided to reduce memory
Freddy Rietdijk
2015-06-19 08:06:36 UTC
Permalink
Hi,

Having read that it is possible to basically 'copy' elements along an axis
without actually copying the values by making use of the strides, I wonder
whether it is possible to add this as an option to np.tile.

It would be easier than having to use as_strided or broadcast_arrays to
repeat data without actually replicating it.

http://stackoverflow.com/questions/23695851/python-repeating-numpy-array-without-replicating-data
https://scipy-lectures.github.io/advanced/advanced_numpy/#example-fake-dimensions-with-strides

Frederik
Sebastian Berg
2015-06-19 17:39:49 UTC
Permalink
Post by Freddy Rietdijk
Hi,
Having read that it is possible to basically 'copy' elements along an
axis without actually copying the values by making use of the strides,
I wonder whether it is possible to add this as an option to np.tile.
No, what tile does cannot be represented that way. If it was possible
you can achieve the same using `np.broadcast_to` basically, which was
just added though. There are some other things you can do, like rolling
window (adding dimensions), maybe some day we should add that (or you
want to take a shot ;)).

- Sebastian
Post by Freddy Rietdijk
It would be easier than having to use as_strided or broadcast_arrays
to repeat data without actually replicating it.
http://stackoverflow.com/questions/23695851/python-repeating-numpy-array-without-replicating-data
https://scipy-lectures.github.io/advanced/advanced_numpy/#example-fake-dimensions-with-strides
Frederik
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Stephan Hoyer
2015-06-19 17:47:18 UTC
Permalink
Post by Sebastian Berg
No, what tile does cannot be represented that way. If it was possible
you can achieve the same using `np.broadcast_to` basically, which was
just added though. There are some other things you can do, like rolling
window (adding dimensions), maybe some day we should add that (or you
want to take a shot ;)).
- Sebastian
The one case where np.tile could be done using stride tricks is if the
dimension you want to repeat has size 1 or currently does not exist.
np.broadcast_to was an attempt to make this stuff less awkward, though it
still requries mixing in transposes.

Loading...