mardi 7 juillet 2020

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() in a for loop

Please help on how I could use a.any() or a.all() in such a case, as my attempt np.all(x[i] == 0 and x[j] == 0) == True and True makes no difference.

def count(x):
    """ similar to q table, if 0 and 0 in consecutive ,then 0.3 is appended in the count_set...."""

count_set = []

for i in range(x.shape[0]):
    for j in range(x.shape[1]):
        
        if x[i] == 0 and x[j] == 0:
            count_set.append(0.3)
        elif x[i] == 0 and  x[j] ==1:
            count_set = append(0.1)
        else :
            count_set.append(0.5)

   
return np.cumsum(count_set)

Aucun commentaire:

Enregistrer un commentaire