numpy

How to calculate all 24 rotations of 3d array?

一世执手 提交于 2021-02-06 14:59:41
问题 I have a 3d numpy array describing a polycube (imagine a 3d tetris piece). How can I calculate all 24 rotations? Numpy's array manipulation routines includes a rot90 method, which gives 4 of the 24, but I'm clueless how to calculate the rest. My only idea is to convert the 3d array to a 2d matrix of co-ordinates, multiply by a rotation matrix, and convert back. But I'd rather work directly with the 3d array. Example 2x2x2 array: >>> from numpy import array >>> polycube array([[[1, 0], [1, 0]]

Shuffling non-zero elements of each row in an array - Python / NumPy

只愿长相守 提交于 2021-02-06 14:23:11
问题 I have a an array that is relatively sparse, and I would like to go through each row and shuffle only the non-zero elements. Example Input: [2,3,1,0] [0,0,2,1] Example Output: [2,1,3,0] [0,0,1,2] Note how the zeros have not changed position. To shuffle all elements in each row (including zeros) I can do this: for i in range(len(X)): np.random.shuffle(X[i, :]) What I tried to do then is this: for i in range(len(X)): np.random.shuffle(X[i, np.nonzero(X[i, :])]) But it has no effect. I've

Shuffling non-zero elements of each row in an array - Python / NumPy

自作多情 提交于 2021-02-06 14:21:25
问题 I have a an array that is relatively sparse, and I would like to go through each row and shuffle only the non-zero elements. Example Input: [2,3,1,0] [0,0,2,1] Example Output: [2,1,3,0] [0,0,1,2] Note how the zeros have not changed position. To shuffle all elements in each row (including zeros) I can do this: for i in range(len(X)): np.random.shuffle(X[i, :]) What I tried to do then is this: for i in range(len(X)): np.random.shuffle(X[i, np.nonzero(X[i, :])]) But it has no effect. I've

reading nested .h5 group into numpy array

戏子无情 提交于 2021-02-06 11:53:53
问题 I received this .h5 file from a friend and I need to use the data in it for some work. All the data is numerical. This the first time I work with these kind of files. I found many questions and answers here about reading these files but I couldn't find a way to get to lower level of the groups or folders the file contains. The file contains two main folders, i.e. X and Y X contains a folder named 0 which contains two folders named A and B. Y contains ten folders named 1-10. The data I want to

How to fit a line through a 3D pointcloud?

六眼飞鱼酱① 提交于 2021-02-06 11:41:33
问题 I have a cable I am dropping from moving vehicle onto the ground. Using a camera system I estimate the location where the rope touches the ground in realtime. Movement of the vehicle and inaccuracy in the estimation of the location result in a point-cloud of touchdown locations. From this point cloud, I'd like to obain the most likely path of the cable lying on the ground. I'd like to achieve this in real-time, and I'd like the fit to be updated according to new data. The frequency of new

How to fit a line through a 3D pointcloud?

北战南征 提交于 2021-02-06 11:40:26
问题 I have a cable I am dropping from moving vehicle onto the ground. Using a camera system I estimate the location where the rope touches the ground in realtime. Movement of the vehicle and inaccuracy in the estimation of the location result in a point-cloud of touchdown locations. From this point cloud, I'd like to obain the most likely path of the cable lying on the ground. I'd like to achieve this in real-time, and I'd like the fit to be updated according to new data. The frequency of new

Unable to solve the XOR problem with just two hidden neurons in Python

可紊 提交于 2021-02-06 11:29:32
问题 I have a small, 3 layer, neural network with two input neurons, two hidden neurons and one output neuron. I am trying to stick to the below format of using only 2 hidden neurons. I am trying to show how this can be used to behave as the XOR logic gate, however with just two hidden neurons I get the following poor output after 1,000,000 iterations! Input: 0 0 Output: [0.01039096] Input: 1 0 Output: [0.93708829] Input: 0 1 Output: [0.93599738] Input: 1 1 Output: [0.51917667] If I use three

Unable to solve the XOR problem with just two hidden neurons in Python

五迷三道 提交于 2021-02-06 11:28:11
问题 I have a small, 3 layer, neural network with two input neurons, two hidden neurons and one output neuron. I am trying to stick to the below format of using only 2 hidden neurons. I am trying to show how this can be used to behave as the XOR logic gate, however with just two hidden neurons I get the following poor output after 1,000,000 iterations! Input: 0 0 Output: [0.01039096] Input: 1 0 Output: [0.93708829] Input: 0 1 Output: [0.93599738] Input: 1 1 Output: [0.51917667] If I use three

Unable to solve the XOR problem with just two hidden neurons in Python

心不动则不痛 提交于 2021-02-06 11:28:02
问题 I have a small, 3 layer, neural network with two input neurons, two hidden neurons and one output neuron. I am trying to stick to the below format of using only 2 hidden neurons. I am trying to show how this can be used to behave as the XOR logic gate, however with just two hidden neurons I get the following poor output after 1,000,000 iterations! Input: 0 0 Output: [0.01039096] Input: 1 0 Output: [0.93708829] Input: 0 1 Output: [0.93599738] Input: 1 1 Output: [0.51917667] If I use three

Unable to solve the XOR problem with just two hidden neurons in Python

老子叫甜甜 提交于 2021-02-06 11:27:48
问题 I have a small, 3 layer, neural network with two input neurons, two hidden neurons and one output neuron. I am trying to stick to the below format of using only 2 hidden neurons. I am trying to show how this can be used to behave as the XOR logic gate, however with just two hidden neurons I get the following poor output after 1,000,000 iterations! Input: 0 0 Output: [0.01039096] Input: 1 0 Output: [0.93708829] Input: 0 1 Output: [0.93599738] Input: 1 1 Output: [0.51917667] If I use three