Questions tagged [stride]

The stride of an array is the number of locations in memory between beginnings of successive array elements, measured in bytes or in units of the size of the array's elements. Arrays may have a stride larger than their elements' width in bytes, which are called a non-unit stride. One particular use of non-unit stride is for images, when creating subimages without copying the pixel data.

The stride of an array is the number of locations in memory between beginnings of successive array elements, measured in bytes or in units of the size of the array's elements. Arrays may have a stride larger than their elements' width in bytes, which are called a non-unit stride. One particular use of non-unit stride is for images, when creating subimages without copying the pixel data.

157 questions
0
votes
0 answers

How to set right strides in MLMultiArray in Core ML? What's the strides' values' meaning?

How to set right strides in MLMultiArray in Core ML? What's the EVERY strides' values' meaning? For example, assume a Core ML model input shape is (1, 3, 1280, 720), so how to set strides when create MLMultiArray object by using…
Smeegol
  • 2,014
  • 4
  • 29
  • 44
0
votes
1 answer

NumPy 'as_strided' for strided sliding window over RGBA image (3D array)

I've done research and looked over several questions on SO to figure out the proper set-up of strides and shape, but it's been giving me problems. I have an image array of shape (250, 250, 4) (example) and need to use as_strided to create a sliding…
Jack Avante
  • 1,405
  • 1
  • 15
  • 32
0
votes
0 answers

Size in bytes of a 4-bit row of pixels?

Take the following example, for a row of pixels that is 2 pixels wide: 4-bit: 1 byte long row (2 pixels = 1 byte) (currently, I get 2 instead of 1) 8-bit: 2 bytes long row, (1 pixel = 1 byte) 16-bit: 4 bytes long row (1 pixel = 2 bytes) 24-bit: 6…
aybe
  • 15,516
  • 9
  • 57
  • 105
0
votes
0 answers

How can i use the stride trick in Karatsuba multiplication of polynomials?

Can someone explain what is the stride trick in general? How can I use it when implementing polynomial multiplication algorithms for which the polynomials are represented as coefficient arrays? How can stride trick make the implementation more…
esra
  • 201
  • 2
  • 8
0
votes
1 answer

Swapping the batch axis has effect on the performance in pytorch?

I know that usually the batch dimension is axis zero, and I imagine this has a reason: The underlying memory for each item in the batch is contiguous. My model calls a function that becomes simpler if I have another dimension in the first axis, so…
Bob
  • 13,867
  • 1
  • 5
  • 27
0
votes
0 answers

sliding window using strides function producing matrix with unknown numbers

where these new numbers are coming from? a=np.arange(21) np.lib.stride_tricks.as_strided(a,(12,3),strides=(8,4))
Ayoti
  • 21
  • 4
0
votes
0 answers

Implications of using np.lib.stride_tricks.as_strided

I have some questions about how np.lib.stride_tricks.as_strided differs from just using np.ndarray and if the as_strided can be intercepted by sub-classes to np.ndarray. Given an array: a = np.arange(10, dtype=np.int8) Is there any difference…
Kevin
  • 3,096
  • 2
  • 8
  • 37
0
votes
0 answers

cupy/numpy, replacing cupy.tile with as_strided

I didn't think this would be as irritating as it has proven to be. I have the following tile call: vertices = cp.tile( vertices, (1, 1, chunk_size, 1), ) I found that, when I printed out the the strides with chunk_size=5, I found that…
Mackie Messer
  • 1,126
  • 2
  • 8
  • 22
0
votes
2 answers

Numpy / Pandas slicing based on intervals

Trying to figure out a way to slice non-contiguous and non-equal length rows of a pandas / numpy matrix so I can set the values to a common value. Has anyone come across an elegant solution for this? import numpy as np import pandas as pd x =…
Brian
  • 210
  • 2
  • 7
0
votes
0 answers

broadcast shapes with stride

Now in numpy version 1.20.0 there is np.broadcast_shapes that will broadcast multiple shapes together, is there something similar but for broadcasting the strides - something like np.broadcast_strides? Say I have two arrays A and B with the…
Kevin
  • 3,096
  • 2
  • 8
  • 37
0
votes
1 answer

Is strided numpy array shared across multiple processes?

Let`s assume that we created a numpy array with views on another array using stride tricks: import numpy as np from numpy.lib import stride_tricks x = np.arange(20).reshape([4, 5]) arr = stride_tricks.as_strided(x, shape=(3, 2, 5),strides=(20, 20,…
Kreol
  • 207
  • 2
  • 7
0
votes
1 answer

Convolutional layer in Python using Numpy - with Strides

My question is highly related to this one, from which I copied the definition: Convolutional layer in Python using Numpy. I am trying to implement a convolutional layer in Python using Numpy. The input is a 4-dimensional array of shape [N, H, W, C],…
EliteKaffee
  • 109
  • 1
  • 2
  • 12
0
votes
1 answer

how strides effect input shapes in keras?

I'm making a simple image classification in keras and I used MaxPooling2D to reduce image sizes. Recently I learned about strides and I want to implement them but I run into errors. Here's a piece of code which gives errors: early_stopping =…
bearthum
  • 107
  • 2
  • 10
0
votes
1 answer

Is stride as an image parameter present in an image file stored in a disc?

I am working with 100×125 size emoji images. To test that our algo works correctly for images with different parameters, I was asked to modify the stride of an image. E.g. "generate test data files where the stride is set to 132 and see if the algo…
mercury0114
  • 1,341
  • 2
  • 15
  • 29
0
votes
0 answers

Transforming a sequence of integers into the binary representation of that sequence's strides

I have a long array of 32 bit integers which represent a time series, e.g. [1,2,3,4,5,6,7,8,9,10,11,12...] (though mine is more or less random) I would like to do two things to do this data to prepare it for its Machine Learning Fate™ in Tensorflow.…
argentage
  • 2,758
  • 1
  • 19
  • 28