Cleaner RunningAverage syntax
See original GitHub issueThe 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:
- Created 5 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i’m going to close this, as the condensed syntax proposed by @jasonkriss seems okay to me
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.