S
S
Stepan Sidorov2020-02-14 20:51:28
Python
Stepan Sidorov, 2020-02-14 20:51:28

How to put a numpy array into a numpy array?

I have such a task:
I need to transfer a one-dimensional array with numbers to the class, and the class must create as many arrays in one numpy array as there are elements and the one-dimensional one that we passed, and with the dimension of each passed element. Example:

class Net():
    def __init__(self, input_list):
        self.output = np.full((len(input_list),2),0.0)#массив в который нужно сложить другие массивы
        for i in range(len(input_list)):
            self.output.функция_добовления_массива_в_массив(input_list[i],2)#здесь добовляем массив в массив и исользуем размерность переданую в каждом из элементов input_list
    def ret(self):
        return self.output#функция возврата полученного массива с массивами

input_list = [20,80,10,10,20,6]
MyNet = Net(input_list)
output = MyNet.ret()


What I need it for:
I need it for neural networks, I am writing my own library, and I need all layers to be stored in one numpy array, and also all neuron connections in one array, so that you can specify the dimension of the neural network.
Also for storing segments of a picture, this is also one of the tasks for a neural network.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Dugin, 2020-02-15
@Stepan47

np.array([np.zeros((i, 2), dtype=np.float32) for i in input_list])

It is not clear why you climb into the neural network if you cannot do the elementary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question