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

numpy.lib.stride_tricks produces different strides for same shaped arrays

I have a dataset that is giving a different number of stride lengths compared to another dataset of the same shape. The dataset can be downloaded from filebin at: https://filebin.net/e02dm84v5etjyxoq while the code that I use is the following, where…
WX_M
  • 458
  • 4
  • 20
0
votes
0 answers

Convolutional layer in tensorflow: stride vs tf.gather

I implemented a convolutional neural network in TensorFlow. However, instead of using the stride operator for the convolutional layers, I use tf.gather to pick every second element. Using this implementation I receive significantly worse results on…
0
votes
1 answer

how to extract overlapping sub-arrays with a window size and flatten them

I am trying to get better at using numpy functions and methods to run my programs in python faster I want to do the following: I create an array 'a' as: a=np.random.randint(-10,11,10000).reshape(-1,10) a.shape: (1000,10) I create another array…
0
votes
1 answer

What is the proper way to use stride in cuda to do multiblock reduction?

Hello everyone I'm trying to use grid-stride method and atomic functions to do multi-block reduction. I know that the usual way to do this is to launch two kernels or use lastblock method as directed in this note.(or this tutorial) However, I…
chanjure
  • 1
  • 1
0
votes
2 answers

Finding max values from given subarrays using numpy's strides

I'm given such 2D-array. My task is to find max values in subarrays painted by different colours. I have to use strides and as_strided. So far my code looked like…
Matthias
  • 59
  • 1
  • 5
0
votes
1 answer

Cuda - 2D Multiple double sums in each Matrix element

Same issue as post (Cuda - Multiple sums in each vector element). How do you perform 2D block striding in both x- and y-direction with varying summation limits. The 2D algorithm can be seen in the CPU and monolithic kernel. I included openmp for the…
0
votes
1 answer

How to calculate final size after multiple convolutions with same padding?

Given I have the following: s: stride k: kernel size i: input size n: number of times a convolution layer was performed With the convolution layer having the following parameters: input = [b, i, i, c] (with batch size b and channel size c) padding…
Spenhouet
  • 6,556
  • 12
  • 51
  • 76
0
votes
2 answers

Recipe to copy 1D strided data with cudaMemcpy2D

If one has two continuous ranges of device memory it is possible to copy memory from from one to the other using cudaMemcpy. double* source = ... double* dest = ... cudaMemcpy(dest, source, N, cudaMemcpyDeviceToDevice); Now suppose that I…
alfC
  • 14,261
  • 4
  • 67
  • 118
0
votes
1 answer

Slice sets of columns in numpy

Consider a numpy array as such: >>> a = np.array([[1, 2, 3, 0, 1], [2, 3, 2, 2, 2], [0, 3, 3, 2, 2]]) >>> a array([[1, 2, 3, 0, 1], [2, 3, 2, 2, 2], [0, 3, 3, 2, 2]]) And an array which contains couples of column indexes to slice (a…
Mattijn
  • 12,975
  • 15
  • 45
  • 68
0
votes
1 answer

extract odd number rows and save them as a new matrix

I am working with eigen library right now, and trying to find a way to extract the odd rows of a matrix into a new matrix. I am currently using Map>dst(eigen_src.data(), eigen_src.rows(), eigen_src.cols() / 2,…
0
votes
3 answers

What is the difference in the Code Snippets?

I am a beginner in operating systems, and I am trying to understand some code snippets. Can you please explain to me the difference between these code snippets?? int sum_array_rows(int a[M][N]) { int i,j,sum=0; for(i=0;i
Jane
  • 77
  • 1
  • 11
0
votes
1 answer

Advantage of using stride in swift

Can you explain the advantage of stride in Swift and its peculiar use? e.g.: for i in stride(from: 0, to: 10, by: 1) { print(i) // prints from 0 to 9 } Instead of this we can use for loop also.
Akash
  • 91
  • 2
  • 12
0
votes
1 answer

How to set Stride, Filter size in Tensorflow for 1-D signals?

I am trying to implement CNN using tensorflow on temporal accelerometer signal. I have signal values segmented on every 10ms (200 samples) I want to perform 1-D convolution: tf.nn.conv1d(x, W, stride=1, padding='VALID') Convolution window size is…
Salman Shaukat
  • 333
  • 3
  • 14
0
votes
5 answers

Punctuation when slicing string in python with stride

For the following code, why is the answer not 'yoif!' with the exclamation mark? >>> s = 'Python is fun!' >>> s[1:12:3] >'yoif' Why is the exclamation mark excluded, since it also has an index number, as shown by the following code (continued…
peractio
  • 593
  • 1
  • 5
  • 14
0
votes
1 answer

numpy.lib.stride_tricks.as_strided resulting typecasts and random values

I am generating sliding windows using np.lib.stride_tricks.as_strided using the following wsize=4 overlap=0 vector=np.array(range(31)) fillval=np.nan part_to_fill=np.full(wsize - (vector.shape[0] - 1) % wsize - 1,fillval) a_ext = np.concatenate((…
00__00__00
  • 4,834
  • 9
  • 41
  • 89