...
87 32.0703961849 seconds / reliability: 0.9795
88 32.0824241638 seconds / reliability: 0.992166666667
89 32.0566852093 seconds / reliability: 0.995333333333
90 32.0832369328 seconds / reliability: 0.992333333333
91 32.0895729065 seconds / reliability: 0.966333333333
92 32.048817873 seconds / reliability: 0.992333333333
93 32.0678329468 seconds / reliability: 0.995
94 32.0670650005 seconds / reliability: 0.995833333333
95 32.429267168 seconds / reliability: 0.9955
96 32.1072170734 seconds / reliability: 0.9925
97 32.0676319599 seconds / reliability: 0.99
98 32.0874857903 seconds / reliability: 0.982333333333
99 32.0707070827 seconds / reliability: 0.991666666667
Blijkbaar door het type vraagstuk.
Dit is de gebruikte code om de graantjes aan te maken. 60.000 plaatjes in ongeveer 9 seconden. Iets minder for-loopjes door sub-matrix bewerkingen.
####################################
t0 = time.time()
si = 60000 # Aantal oefenafbeeldingen
t_si = -.1 * si # testset 10%
h = 28 # hoogte
b = 28 # breedte
r = 3 # (max) graan-grootte + 2
a = 5 # (max) aantal graantjes
ima = np.zeros((si, h * b))
ima.shape = si, h , b
grains = np.floor(np.random.rand(si) * a) + 1 #minimaal 1 graantje
num = np.zeros((si,10))
for i in range(si):
num[i,int(grains[i])]=1.
for i in range(0,si):
for j in range(0,int(grains[i])):
notfree = True
while notfree:
ho = np.floor(np.random.rand() * (h-r))
br = np.floor(np.random.rand() * (b-r))
vr = 2 + np.floor(np.random.rand() * r)
#vr = r
notfree= np.sum(ima[i,int(ho):int(ho+vr),int(br):int(br+vr)])!=0 # Test of er plaats is voor het 'graantje'.
ima[i,int(ho):int(ho+vr),int(br):int(br+vr)] += 1
ima.shape = si, h * b
trX,trY = ima[:t_si], num[:t_si]
teX,teY = ima[t_si:], num[t_si:]
print 'test files generated', time.time() - t0, 'seconds'
####################################
Geen opmerkingen:
Een reactie posten