class_docstr: CWR* Strategy.
  
  This plugin does not use task identities.
class_docstr_tok: ["CWR","*","Strategy",".","This","plugin","does","not","use","task","identities","."]
docstr: Mean-shift for the target layer weights
docstr_tok: ["Mean-shift","for","the","target","layer","weights"]
code: def consolidate_weights(self):
      """Mean-shift for the target layer weights"""
  
      with torch.no_grad():
          cwr_layer = self.get_cwr_layer()
          assert cwr_layer is not None, "Could not find the CWR layer."
          # calculate the average of the current classes
          globavg = np.average(
              cwr_layer.weight.detach().cpu().numpy()[self.cur_class]
          )
          for c in self.cur_class:
              w = cwr_layer.weight.detach().cpu().numpy()[c]
              # subtract the weight average to the weights
              # to obtain zero mean
              new_w = w - globavg
              # if the class has been already seen
              if c in self.model.saved_weights.keys():
                  wpast_j = np.sqrt(
                      self.model.past_j[c] / self.model.cur_j[c]
                  )
                  # consolidation
                  self.model.saved_weights[c] = (
                      self.model.saved_weights[c] * wpast_j + new_w
                  ) / (wpast_j + 1)
                  self.model.past_j[c] += self.model.cur_j[c]
              else:
                  # new class
                  self.model.saved_weights[c] = new_w
                  self.model.past_j[c] = self.model.cur_j[c]
  
file_path: avalanche/avalanche/training/plugins/cwr_star.py
imports: import logging
  from collections import defaultdict
  from typing import Optional
  import numpy
  import torch
  from torch.nn import Linear
  from avalanche.training.plugins.strategy_plugin import SupervisedPlugin
  from avalanche.training.utils import examples_per_class, get_last_fc_layer, get_layer_by_name, freeze_everything, unfreeze_everything
label_desc: Use image node_id 4 for calling the CWRStarPlugin obj's underlying member method code with example usage: obj.consolidate_weights() without return types