(self, metadata)
Add activations.
Add activations.
Add activations .
def _add_activations(self, metadata):
        """Add activations."""
        X_batch = metadata.get('X_batch')
        timestamps = metadata.get('timestamps')

        if self.ts is not None and self.ts not in timestamps:
            return

        ix = timestamps.index(self.ts) if self.ts is not None else list(range(len(X_batch)))
        self.writer.add_histogram(tag='inputs', values=X_batch[ix], global_step=self.counter)

        for s, io in self.activations.items():
            for i, x in enumerate(io):
                if torch.is_tensor(x):
                    self.writer.add_histogram(s.__class__.__name__ + "_{}".format('inp' if i == 0 else 'out'),
                                              x[ix],
                                              global_step=self.counter)
                else:
                    for j, y in enumerate(x):
                        if y is None:
                            continue  # pragma: no cover
                        self.writer.add_histogram(s.__class__.__name__ + "_{}_{}".format('inp' if i == 0 else 'out', j),
                                                  y[ix],
                                                  global_step=self.counter)

        for handle in self.handles:
            handle.remove()

        self.handles = []
        self.activations = {}

        self.counter += 1
def _add_activations ( self , metadata ) : X_batch = metadata . get ( 'X_batch' ) timestamps = metadata . get ( 'timestamps' ) if self . ts is not None and self . ts not in timestamps : return ix = timestamps . index ( self . ts ) if self . ts is not None else list ( range ( len ( X_batch ) ) ) self . writer . add_histogram ( tag = 'inputs' , values = X_batch [ ix ] , global_step = self . counter ) for s , io in self . activations . items ( ) : for i , x in enumerate ( io ) : if torch . is_tensor ( x ) : self . writer . add_histogram ( s . __class__ . __name__ + "_{}" . format ( 'inp' if i == 0 else 'out' ) , x [ ix ] , global_step = self . counter ) else : for j , y in enumerate ( x ) : if y is None : continue # pragma: no cover self . writer . add_histogram ( s . __class__ . __name__ + "_{}_{}" . format ( 'inp' if i == 0 else 'out' , j ) , y [ ix ] , global_step = self . counter ) for handle in self . handles : handle . remove ( ) self . handles = [ ] self . activations = { } self . counter += 1