How to sort a batch of 2D tensors in tensorflow?

I have a tensor A with the shape of [#batch, #MaxSequence, #Features], where the actual lengths of the 2nd dimension (may be less than #MaxSequence) are stored in a tensor L. I want to sort A by the 2nd feature in the 3rd dimension on the sequence in...
more »

2017-10-04 20:10 (1) Answers

Adding 2 matrices using pointers

I can acheive it by passing (c,a,b) to add_mat function, where result of a,b is stored in c like, void add_mat(int c[][3], int a[][3], int b[][3], int m, int n) What should be the return type of add_mat if I want to construct the funtion in this w...
more »

2017-10-01 15:10 (3) Answers

numpy binned mean, conserving extra axes

It seems I am stuck on the following problem with numpy. I have an array X with shape: X.shape = (nexp, ntime, ndim, npart) I need to compute binned statistics on this array along npart dimension, according to the values in binvals (and some bins), ...
more »

2017-09-28 13:09 (2) Answers

Inconsistent python print output

(Python 2.7.12) - I have created an NxN array, when I print it I get the exact following output: Sample a: SampleArray=np.random.randint(1,100, size=(5,5)) [[49 72 88 56 41] [30 73 6 43 53] [83 54 65 16 34] [25 17 73 10 46] ...
more »

2017-09-27 14:09 (3) Answers

Sort a multidimensional array by date Laravel

I need to sort a multidimensional array by date. The data is serialized in a column called prices that contains few values: prices and date. I unserialized this in my controller and I've got $hlisting->prices. I think that this prices is an array and...
more »

2017-09-26 15:09 (1) Answers

Refactor multidimensional array function to ES6

Currently putting together a function in my app and was wondering if theres a neater way to write this with ES6 rather than use two for loops. The aim is create a multi-dimensional array to track co-ordinates x & y. This works fine as it stands...
more »

2017-09-19 19:09 (2) Answers

How do I group elements of a numpy array by two?

I am facing the following problem. I have an np.array, of the following structure: [A, B, C, D, E, F] where A..F are numpy arrays, guaranteed to be of the same size. I am hoping to achieve the following shape: [ A | B, C | D, E | F ] where A | ...
more »

2017-09-12 18:09 (2) Answers

C Programming - Sum of 2D arrays

I am trying to get the values of diagonal values from a 2D array. For example.. 10 20 30 10 20 30 10 20 30 From my codes, I will be adding/summing the numbers from index[0][0] with index1 and index[2][2] USING POINTERS which will compute to 60. H...
more »

2017-09-10 11:09 (3) Answers

Get indices and values of an ndarray in NumPy

I have a ndarray A of arbitrary number of dimensions N. I want to create an array B of tuples (array, or lists) where the first N elements in each tuple are the index and the last element is the value of that index in A. For example: A = array([[1...
more »

2017-09-08 03:09 (2) Answers

The order of axis when printing a NumPy array

I am working with 3d arrays in NumPy, and I have to look at the array elements a lot. Say I have array a where a.shape is (10,5,3). I am using this is the sense of 3 planes of shape (10,5), and I would like to view it as such. For example if I pr...
more »

2017-09-06 15:09 (3) Answers

2-dimensional array name 1st element

C Programming in One Hour a Day has this quote: As with a one-dimensional array, the name of a multidimensional array is a pointer to the first array element. #include <stdio.h> int m[2][4]; int main() { printf("%p\n", m); /...
more »

2017-09-05 06:09 (3) Answers

Dot product between 2D and 3D numpy arrays

I have 2 arrays x and y with shapes (2, 3, 3), respectively, (3, 3). I want to compute the dot product z with shape (2, 3) in the following way: x = np.array([[[a111, a121, a131], [a211, a221, a231], [a311, a321, a331]], [[a112, a122,...
more »

2017-08-29 18:08 (1) Answers

Array of 3 Dimensions to an Array of Objects

Been stuck on this for a while. let employees = [ [ ['firstName', 'Joe'], ['lastName', 'Blow'], ['age', 42], ['role', 'clerk'] ], [ ['firstName', 'Mary'], ['lastName', 'Jenkins'], ['age', 36], ['role', 'manager'] ] ] To yield: ...
more »

2017-08-26 07:08 (6) Answers