I have some weights that are generated via the command:
weights = np.random.rand(9+1, 8)
for i in range(8): # 7 to 8
weights[9][i] = random.uniform(.5,1.5)
Then, I try to insert it into an element of the following lattice:
lattice = np.zeros((2,10,5))
lattice[0][0][0] = weights
print(lattice)
This results in the error:
ValueError: setting an array element with a sequence.
My question is:
How can I insert the weights into the lattice?
I am aware that the problem is that the lattice is filled with float values, so it cannot accept a matrix.
I'm interested in finding a way to generate a lattice with the correct number of elements so that I can insert my matrices. An example would be very helpful.
I've read several posts on stackoverflow, including:
how to append a numpy matrix into an empty numpy array
weightsis a (10,8) array of floats.laticeis a (2,10,5) array of floats.. It doesn't make any sense to talk of puttingweightsinlatice.latice[0,0,0]is the slot for ONE float, not 80.latice, it either needs to be object dtype (which makes it list like), or have enough dimensions so thatlatice[0,0,0].shapeis (10,8).