class_docstr: Riemannian Walk (RWalk) plugin.
  RWalk computes the importance of each weight at the end of every training
  iteration, and updates each parameter's importance online using moving
  average. During training on each minibatch, the loss is augmented
  with a penalty which keeps the value of a parameter close to the
  value it had on previous experiences, proportional to a score that has
  high values if small changes cause large improvements in the loss.
  This plugin does not use task identities.
  
  .. note::
      To reproduce the results of the paper in class-incremental scenarios,
      this plug-in should be used in conjunction with a replay strategy
      (e.g., :class:`ReplayPlugin`).
class_docstr_tok: ["Riemannian","Walk","(","RWalk",")","plugin",".","RWalk","computes","the","importance","of","each","weight","at","the","end","of","every","training","iteration",",","and","updates","each","parameter","'s","importance","online","using","moving","average",".","During","training","on","each","minibatch",",","the","loss","is","augmented","with","a","penalty","which","keeps","the","value","of","a","parameter","close","to","the","value","it","had","on","previous","experiences",",","proportional","to","a","score","that","has","high","values","if","small","changes","cause","large","improvements","in","the","loss",".","This","plugin","does","not","use","task","identities",".","..","note",":",":","To","reproduce","the","results","of","the","paper","in","class-incremental","scenarios",",","this","plug-in","should","be","used","in","conjunction","with","a","replay","strategy","(","e.g.",",",":","class",":","`","ReplayPlugin","`",")","."]
code: def after_training_exp(self, strategy, *args, **kwargs):
      assert self.iter_importance is not None
      self.exp_importance = self.iter_importance
      self.exp_params = copy_params_dict(strategy.model)
  
      if self.exp_scores is None:
          self.exp_scores = self.checkpoint_scores
      else:
          exp_scores = {}
  
          for k, p_cp_score in self.checkpoint_scores.items():
              if k not in self.exp_scores:
                  continue
              p_score = self.exp_scores[k]
              shape = p_cp_score.data.shape
              exp_scores[k] = ParamData(
                  k,
                  device=p_score.device,
                  init_tensor=0.5
                  * (p_score.expand(shape) + p_cp_score.data),
              )
          self.exp_scores = exp_scores
  
      # Compute weight penalties once for all successive iterations
      # (t_k+1 variables remain constant in Eq. 8 in the paper)
      self.exp_penalties = {}
  
      # Normalize terms in [0,1] interval, as suggested in the paper
      # (the importance is already > 0, while negative scores are relu-ed
      # out, hence we scale only the max-values of both terms)
      max_score = max(
          map(lambda x: x.data.max(), self.exp_scores.values())
      )
      max_imp = max(
          map(lambda x: x.data.max(), self.exp_importance.values())
      )
  
      for k, score in self.exp_scores.items():
          if k not in self.exp_importance:
              continue  # some params may not have gradients
          imp = self.exp_importance[k]
          shape = imp.data.shape
          self.exp_penalties[k] = ParamData(
              k,
              device=imp.device,
              init_tensor=imp.data / max_imp
              + F.relu(score.expand(shape)) / max_score,
          )
  
      self.checkpoint_scores = zerolike_params_dict(strategy.model)
  
file_path: avalanche/avalanche/training/plugins/rwalk.py
imports: from typing import Dict, Optional
  import warnings
  import torch
  import torch.nn.functional
  from avalanche.training.plugins.strategy_plugin import SupervisedPlugin
  from avalanche.training.utils import copy_params_dict, zerolike_params_dict, ParamData
  from avalanche.models.utils import avalanche_forward
label_desc: Use image node_id 11 for calling the RWalkPlugin obj's underlying member method code with example usage: obj.after_training_exp(strategy) without return types