Skip to content
Advertisement

Tag: arrays

Creating 3d Tensor Array from 2d Array (Python)

I have two numpy arrays (4×4 each). I would like to concatenate them to a tensor of (4x4x2) in which the first ‘sheet’ is the first array, second ‘sheet’ is the second array, etc. However, when I try np.stack the output of d[1] is not showing the correct values of the first matrix. Answer If you do np.dstack((x, y)), which

How to change 12 random 0 to 1 in python Matrix

My program is suppose to change 12 zeros on random positions to 1 in python 6×6 matrix. This is my code. So my matrix is going to look like this at the beggining So I randomly chose an array and the element in chosen array. The problem is that different number of zeros is changed every time. Not 12 like

Advertisement