Shortcuts

pytorch_lightning.trainer.supporters module

class pytorch_lightning.trainer.supporters.TensorRunningAccum(window_length)[source]

Bases: object

Tracks a running accumulation values (min, max, mean) without graph references.

Examples

>>> accum = TensorRunningAccum(5)
>>> accum.last(), accum.mean()
(None, None)
>>> accum.append(torch.tensor(1.5))
>>> accum.last(), accum.mean()
(tensor(1.5000), tensor(1.5000))
>>> accum.append(torch.tensor(2.5))
>>> accum.last(), accum.mean()
(tensor(2.5000), tensor(2.))
>>> accum.reset()
>>> _= [accum.append(torch.tensor(i)) for i in range(13)]
>>> accum.last(), accum.mean(), accum.min(), accum.max()
(tensor(12.), tensor(10.), tensor(8.), tensor(12.))
_agg_memory(how)[source]
append(x)[source]

Add an element to the accumulator.

last()[source]

Get the last added element.

max()[source]

Get maximal value from stored elements.

mean()[source]

Get mean value from stored elements.

min()[source]

Get minimal value from stored elements.

reset()[source]

Empty the accumulator.

Return type

None