          logger.debug("Initialized %s", self.__class__.__name__)
  
      def refresh(self):
          """ Refresh the stats """
          logger.debug("Refreshing")
          if not Session.is_loaded:
              logger.warning("Session data is not initialized. Not refreshing")
 
</s> remove         if not self.session.initialized:
 </s> add         if not Session.is_loaded: </s> remove         self.iterations = 0
        self.stats = self._get_raw()
        self.get_calculations()
        self.remove_raw()
 </s> add         self._iterations = 0
        self._get_raw()
        self._get_calculations()
        self._remove_raw() </s> remove         self.session = session
        self.display = display
        self.loss_keys = loss_keys
        self.selections = selections
        self.is_totals = is_totals
        self.args = {"avg_samples": avg_samples,
                     "smooth_amount": smooth_amount,
                     "flatten_outliers": flatten_outliers}
        self.iterations = 0
        self.stats = None
 </s> add         self._session_id = session_id

        self._display = display
        self._loss_keys = loss_keys if isinstance(loss_keys, list) else [loss_keys]
        self._selections = selections if isinstance(selections, list) else [selections]
        self._is_totals = session_id is None
        self._args = dict(avg_samples=avg_samples,
                          smooth_amount=smooth_amount,
                          flatten_outliers=flatten_outliers)
        self._iterations = 0
        self._limit = 0
        self._start_iteration = 0
        self._stats = dict() </s> remove         if self._session is None:
 </s> add         if not Session.is_loaded: </s> remove     def __init__(self, session):
        logger.debug("Initializing %s: (session: %s)", self.__class__.__name__, session)
        self.session = session
        logger.debug("Initialized %s", self.__class__.__name__)
 </s> add         Parameters
        ----------
        session_id: int
            The session id to compile the stats for
        timestamps:
            The time stamp summary data for the given session id
    @property
    def iterations(self):
        """ int: The number of iterations in the data set. """
        return self._iterations

    @property
    def start_iteration(self):
        """ int: The starting iteration number of a limit has been set on the amount of data. """
        return self._start_iteration

    @property
    def stats(self):
        """ dict: The final calculated statistics """
        return self._stats

          logger.debug("Initialized %s", self.__class__.__name__)
  
    @property
    def iterations(self):
        """ int: The number of iterations in the data set. """
        return self._iterations

    @property
    def start_iteration(self):
        """ int: The starting iteration number of a limit has been set on the amount of data. """
        return self._start_iteration

    @property
    def stats(self):
        """ dict: The final calculated statistics """
        return self._stats

      def refresh(self):
          """ Refresh the stats """
          logger.debug("Refreshing")
          if not Session.is_loaded:
              logger.warning("Session data is not initialized. Not refreshing")
keep add keep keep keep keep keep
 GUI - Stats optimization (#1067)

* Faster stat loading + caching

* Compress data in cache

* Optimize some calculations

* Vectorize smoothing

* stats.Calculations optimized

* Load latest training data from live iterator

* Add options to training graph 
lib/gui/stats.py