Skip to content

Commit

Permalink
Merge pull request #2195 from Foxglove144/patch-1
Browse files Browse the repository at this point in the history
Fix ragged nested sequence warning
  • Loading branch information
beat-buesser authored Jun 30, 2023
2 parents 82f8fa2 + 6250986 commit e3708eb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions art/defences/detector/poison/clustering_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ def analyze_by_size(self, separated_clusters: List[np.ndarray]) -> Tuple[np.ndar
all_assigned_clean = []
nb_classes = len(separated_clusters)
nb_clusters = len(np.unique(separated_clusters[0]))
summary_poison_clusters: np.ndarray = np.zeros((nb_classes, nb_clusters))
summary_poison_clusters: np.ndarray = np.zeros((nb_classes, nb_clusters), dtype=object)

for i, clusters in enumerate(separated_clusters):

# assume that smallest cluster is poisonous and all others are clean
sizes = np.bincount(clusters)
total_dp_in_class = np.sum(sizes)
Expand All @@ -98,8 +97,8 @@ def analyze_by_size(self, separated_clusters: List[np.ndarray]) -> Tuple[np.ndar

report["Class_" + str(i)] = report_class

report["suspicious_clusters"] = report["suspicious_clusters"] + np.sum(summary_poison_clusters).item()
return np.asarray(all_assigned_clean), summary_poison_clusters, report
report["suspicious_clusters"] = report["suspicious_clusters"] + np.sum(summary_poison_clusters)
return np.asarray(all_assigned_clean, dtype=object), summary_poison_clusters, report

def analyze_by_distance(
self,
Expand Down Expand Up @@ -187,7 +186,7 @@ def analyze_by_distance(
assigned_clean = self.assign_class(clusters, clean_clusters, np.array(poison_clusters))
all_assigned_clean.append(assigned_clean)

all_assigned_clean_array = np.asarray(all_assigned_clean)
all_assigned_clean_array = np.asarray(all_assigned_clean, dtype=object)
return all_assigned_clean_array, summary_poison_clusters, report

def analyze_by_relative_size(
Expand Down

0 comments on commit e3708eb

Please sign in to comment.