question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cleaner RunningAverage syntax

See original GitHub issue

The current way to add multiple running averages computed over the output is a bit too verbose imo, and it can be made simpler.

DCGAN Example:

    def step(engine, batch):

       (...)

        return {
            'errD': errD.item(),
            'errG': errG.item(),
            'D_x': D_x,
            'D_G_z1': D_G_z1,
            'D_G_z2': D_G_z2
        }

Current API

To compute running averages over all of these, I would have to create an object per output and call the attach method:

    avg_err_d = RunningAverage(output_transform=lambda x: x['errD'])
    avg_err_d.attach(trainer, 'errD')
    avg_err_g = RunningAverage(output_transform=lambda x: x['errG'])
    avg_err_g.attach(trainer, 'errG')
    avg_dx = RunningAverage(output_transform=lambda x: x['D_x'])
    avg_dx.attach(trainer, 'D_x')
    avg_dg_z1 = RunningAverage(output_transform=lambda x: x['D_G_z1'])
    avg_dg_z1.attach(trainer, 'D_G_z1')
    avg_dg_z2 = RunningAverage(output_transform=lambda x: x['D_G_z2'])
    avg_dg_z2.attach(trainer, 'D_G_z2')

Proposed API

Initialize one RunningAverage object and pass the output_transform function to the attach method

    running_avgs = RunningAverage()
    running_avgs.attach(trainer, 'errD', output_transform=lambda x: x['errD'])
    running_avgs.attach(trainer, 'errG', output_transform=lambda x: x['errG'])
    running_avgs.attach(trainer, 'D_x', output_transform=lambda x: x['D_x'])
    running_avgs.attach(trainer, 'D_G_z1', output_transform=lambda x: x['D_G_z1'])
    running_avgs.attach(trainer, 'D_G_z2', output_transform=lambda x: x['D_G_z2'])

cc @vfdev-5

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
miguelvrcommented, Sep 30, 2018

i’m going to close this, as the condensed syntax proposed by @jasonkriss seems okay to me

0reactions
jasonkrisscommented, Sep 29, 2018

You’re right. There is no compatibility. Not sure what i was thinking 😃.

Yea i mean in general, but since the create_supervised_* functions are the only explicit place where we define process functions, that’s where it would show up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Particle RunningAverage
The runningAverage library makes a class of the function above so it can be used multiple times in an sketch. It decouples the...
Read more >
RobTillaart/RunningAverage: Arduino library to ... - GitHub
The RunningAverage object gives a running average of the last N floating point numbers, giving them all equal weight. This is done by...
Read more >
Running Average for Your Microcontroller Projects : 6 Steps
1. Arduino has a decent 10 bit ADC with very little noise. When measuring value on a sensor such as potentiometer, photoresistor or...
Read more >
Pandas & Numpy Moving Average & Exponential ... - DataCamp
A moving average, also called a rolling or running average, is used to analyze the time-series data by calculating averages of different subsets...
Read more >
Structured Streaming Programming Guide - Apache Spark
Spark may not clean up some source files in some circumstances - e.g. the ... groupBy("deviceType").count() // using untyped API // Running average...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found