From d1cd450ea610ecd181cf71c7ec1e3fab2017fe01 Mon Sep 17 00:00:00 2001
From: Neta Zmora <neta.zmora@intel.com>
Date: Sun, 25 Nov 2018 17:53:45 +0200
Subject: [PATCH] Activation statistics: change the APoZ sorting order

When ranking filters by APoZ, we need to change the sort order, to match
that of module.apoz_channels.value().  This is the result of the previous
bug fix.
---
 distiller/pruning/ranked_structures_pruner.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/distiller/pruning/ranked_structures_pruner.py b/distiller/pruning/ranked_structures_pruner.py
index 9097c5d..8697d23 100755
--- a/distiller/pruning/ranked_structures_pruner.py
+++ b/distiller/pruning/ranked_structures_pruner.py
@@ -206,8 +206,8 @@ class ActivationAPoZRankedFilterPruner(RankedFiltersParameterPruner):
             msglogger.info("Too few filters - can't prune %.1f%% filters", 100*fraction_to_prune)
             return
 
-        # Sort from high to low, and remove the bottom 'num_filters_to_prune' filters
-        filters_ordered_by_apoz = np.argsort(-apoz)[:-num_filters_to_prune]
+        # Sort from low to high, and remove the bottom 'num_filters_to_prune' filters
+        filters_ordered_by_apoz = np.argsort(apoz)[:-num_filters_to_prune]
         zeros_mask_dict[param_name].mask = RankedFiltersParameterPruner.mask_from_filter_order(filters_ordered_by_apoz,
                                                                                                param, num_filters)
 
-- 
GitLab