All Questions
505
questions
1
vote
3
answers
58
views
Equivalence between reshape, strides and transpose? (numpy)
i am sorry for the very naive question.
I have these lines of numpy code, with a transpose at the beginning, and strides and reshape are used afterward.
I wonder if by re-ordering indices in reshape ...
0
votes
1
answer
46
views
this code show an reshape error. how fix this?
I'm new in python and ML. I wrote this code for practicing. It displays this error. how do I solve this reshape problem?
import pandas as pd
import sklearn as skl
data=pd.read_csv('housing.csv')
...
0
votes
1
answer
90
views
How to reshape (n,) array to (n,3) array? [closed]
I have an array with (n,) dimension and for a project I need to have this array with (n,3) shape.
This array is a set of a 3-dimensional points.
This is the code :
vertices = np.array([line[7:] for ...
0
votes
0
answers
40
views
Performance of numpy matrix vector product on scipy.stats.qmc.Sobol vector when changing reshaping order
Solution at the bottom.
I am trying to implement a Brownian bridge and want to speed up the path construction via numpy matrix multiplication, once the bridge is initialised. I am drawing data for 3 ...
-1
votes
1
answer
56
views
Numpy reshape() to display 2D array in 3D programmatically
Example Data
I have an array of weather data by lat/lon in the following shape: (1038240,4) (See photo for sample example data)
I want to reshape this to the shape (4,721,1440) which would be four ...
1
vote
1
answer
26
views
Converting two 2d arrays of different shapes into a 3d array
How to convert two 2d arrays of shapes (629, 5) and (629, 6) into a 3d array of shape (629, 5, 6)?
Input:
[[2, 5, 6, 7, 8],
[3, 5, 6, 7, 8],
[4, 5, 6, 7, 8]]
[[2, 5, 6, 7, 8, 9],
[3, 5, 6, 7, 8, 9]...
0
votes
0
answers
13
views
Reshape LSTM Layer Input Tensorformat
I have a table with 4700 rows and 50 columns. The last 3 columns should be predicted.
How do I have to set up my X and my y to be able to enter it in an LSTM layer?
X = (?, ?, ?)
y = (?, ?)
I ...
0
votes
1
answer
165
views
numpy reshape implementation
My main focus will on this page.
First, I don't understand the page. For the first parameter shape,
ndarray.reshape(shape, order='C')
why this method on ndarray allows the elements of the shape ...
1
vote
3
answers
100
views
"Reshape" along a specific axis - Numpy
I have a 4D numpy array. For example I have 2 batches of 3 two-dimensional matrices with a shape of (2, 3, 4, 5).
In each batch, I want to concatenate the three 2D matrices horizontally (over the last ...
0
votes
1
answer
39
views
Reshape object with shape (500,)
I'm using the following code to reshape an object with shape (625,):
u1 = np.linspace(16, 20, 25)
u2 = np.linspace(16, 20, 25)
u1, u2 = np.meshgrid(u1, u2)
U = np.vstack((u1.flatten(), u2.flatten()))
...
0
votes
1
answer
44
views
How to you concat inner matrixes of tensor along axis?
Let we have a tensor with shape $n\times d\times h\times w\times p\times p$ and we want to concat innet matrix with shape $p\time p$, such that we made a matrix with shape $n\times d\times ph\times pw$...
0
votes
1
answer
90
views
reshaping rows and columns and then converting to numpy array
Following DataFrame contains integer values. I want them to reshaped into a new column where every row will be represented, as a combination of each 3 rows of each columns from old dataframe.
import ...
0
votes
1
answer
47
views
Numpy reshape image to column major order is duplicating my picture
For Self supervised learning purpose, I need to create a dataset composed of custom pictures.
I want to store my pictures in a bin file, as numpy array in the shape (3, 256, 256) in column major order....
1
vote
1
answer
72
views
Why does .reshape(a, b) != .reshape(b, a).T?
I ran into this problem whilst flattening images. Consider the following array
>>> import numpy as np
>>> arr = np.array([[[1, 2],
[3, 4]],
[[...
1
vote
1
answer
41
views
reshape 2d numpy array with most frequent elements
I would like to reshape 2d numpy arrays to smaller shapes and populate it with the most frequent elements within a specified block.
For example to go from a shape (4,4) to (2,2) I can use reshape and ...