I have an array which is called the group:
Syntax: Select all
import numpy as np
group = np.array(
[[[0,0,1,0,0],
[0,1,0,1,0],
[0,1,0,1,0],
[0,1,0,1,0],
[0,0,1,0,0]],
[[0,0,1,0,0],
[0,1,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,1,1,1,0]],
[[0,1,1,0,0],
[0,1,0,1,0],
[0,0,1,0,0],
[0,1,0,0,0],
[0,1,1,1,0]],
[[0,1,1,1,0],
[0,0,1,0,0],
[0,1,1,1,0],
[0,0,0,1,0],
[0,1,1,1,0]],
[[0,0,1,1,0],
[0,1,0,1,0],
[0,1,1,1,0],
[0,0,0,1,0],
[0,0,0,1,0]],
[[0,1,1,1,0],
[0,1,0,0,0],
[0,1,1,1,0],
[0,0,0,1,0],
[0,1,1,1,0]],
[[0,0,0,1,0],
[0,0,1,0,0],
[0,1,1,1,0],
[0,1,0,1,0],
[0,1,1,1,0]],
[[0,1,1,1,0],
[0,0,0,1,0],
[0,0,1,0,0],
[0,1,0,0,0],
[0,1,0,0,0]],
[[0,1,1,1,0],
[0,1,0,1,0],
[0,0,1,0,0],
[0,1,0,1,0],
[0,1,1,1,0]],
[[0,1,1,1,0],
[0,1,0,1,0],
[0,1,1,1,0],
[0,0,1,1,0],
[0,1,0,1,0]]])
>
dataSetSize = group.shape[0]
>
a1=[
[1 1 0 1 0]
[0 0 0 0 0]
[0 0 1 1 1]
[1 0 1 0 1]
[0 0 0 1 0]]
def tile(your_array, your_database, n):
m=your_database[:]
for i in range(n):
newarr=your_array - m[i]
return newarr
print newarr
I need to substract an array your_array (is the a1) from an element of an array of the arrays is called your_database (is the group). I try to specify an index of your_database (is the group) , but python says that your_database[:] and m[i] has no attribute getitem()
Then i wrote this code:
Syntax: Select all
def tile(your_array, your_database, n):
m=your_database.__getitem__()
for i in range(n):
yy=m.__getitem__(i)
newarr=your_array - yy
return newarr
print newarr
But i get an error : 'long' object has no attribute 'getitem'
This function i have written and try to run my code and a mistake occurs at the line #185 . This number of line in my def tile. Thus i haven't called this function, but my code contains it.
1st variant of def tile in tile m=your_database[:] TypeError: 'long' object has no attribute 'getitem'
2nd variant of def tile in tile m=your_database.getitem() AttributeError: 'long' object has no attribute 'getitem'
These function i write to get an substracted array from: a1 - group[i], where i - an element of the big array group .
As i understand right if i specify n - this is numbers of elements of big array (is the group)
Being passed for i'd get my substracted arrays (5*5)
If you have an idea how to substract element of big array *(Element of big array have same size like as array(5*5))* from an array (5*5)