Exemplo n.º 1
0
                        wtolu, ukk, zipf, stype)
 else:
     if stype == 3 and type(zipf) == float and zipf < 0:
         result = sm.dg4(root + name, cll, b, s, p, wtolu, ltow,
                         ukk, vecu)
     else:
         result = sm.dg2(root + name, cll, sys.argv[3], b, s,
                         wtolu, ukk, zipf, vecu, stype)
 dlu = np.array([10.0 for i in range(0, len(result) - 1)])
 mt = []
 sim = []
 for i in range(0, len(result) - 1):
     if count == 6:
         vect[i] = sm.vecof(result[i], a, wtola, akk)
         mt.append(vect[i].max())
         sim.append(attack.simatt(result[i], pu))
         vecut[i] = sm.vecof0(result[i], b, s, wtolu, ukk)
     else:
         vecr = sm.vecof(result[i], a, wtola, akk)
         mt.append(vecr.max())
         sim.append(attack.simatt(result[i], pu))
         vecur = sm.vecof0(result[i], b, s, wtolu, ukk)
         for j in range(0, len(result) - 1):
             dlt = spatial.distance.cosine(vecur, vecu[j])
             if (dlt < dlu[i]):
                 dlu[i] = dlt
                 vecut[i] = vecu[j]
         vecut[i] = (vecur + vecut[i] * count) / (count + 1)
 for i in range(0, len(result) - 1):
     vecu[i] = vecut[i]
 if count > 6:
Exemplo n.º 2
0
 dlu = np.array([10.0 for i in range(0, len(result) - 1)])
 sim = np.array([0.0 for i in range(0, len(result) - 1)])
 mt = []
 for i in range(0, len(result) - 1):
     if count == 1:
         vect[i] = sm.vecof(result[i], a, wtola, akk)
         mt.append(vect[i].max())
         vecut[i] = sm.vecof0(result[i], b, s, wtolu, ukk)
         put[i].append(result[i][0:-2])
     else:
         vecr = sm.vecof(result[i], a, wtola, akk)
         mt.append(vecr.max())
         vecur = sm.vecof0(result[i], b, s, wtolu, ukk)
         for j in range(0, len(result) - 1):
             dlt = spatial.distance.cosine(vecur, vecu[j])
             simt = attack.simatt(result[i], pu[j])
             if (simt > sim[i]):
                 sim[i] = simt
                 put[i] = pu[j]
             if (dlt < dlu[i]):
                 dlu[i] = dlt
                 vecut[i] = vecu[j]
         put[i].append(result[i][0:-2])
         vecut[i] = (vecur + vecut[i] * count) / (count + 1)
 for i in range(0, len(result) - 1):
     vecu[i] = vecut[i]
     pu[i] = put[i]
 if count > 1:
     total = total + 1
     if np.array(sim).argmax() == int(result[-1]):
         hit = hit + 1