Skip to content

Commit

Permalink
Merge pull request #584 from autonomio/fix_powerdraw_callback
Browse files Browse the repository at this point in the history
Fix powerdraw callback
  • Loading branch information
mikkokotila committed Apr 15, 2022
2 parents 4eb8712 + d206143 commit 17c1036
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
16 changes: 9 additions & 7 deletions docs/Energy_Draw.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ A callback for recording GPU power draw (watts) on epoch begin and end. The call

### how-to-use

Use it as you would use any other Callback in Tensorflow or Keras.
Before `model.fit()` in the input model:

`
power_draw = PowerDrawCallback()
`power_draw = PowerDrawCallback()`

model.fit(...callbacks=[power_draw]...)
`
Then use `power_draw` as you would callbacks in general:

It's possible to read the energy draw data:
`model.fit(...callbacks=[power_draw]...)`

`print(power_draw.logs)`
To get the energy draw data into the experiment log:

`history = talos.utils.power_draw_append(history, power_draw)`

NOTE: this line has to be after `model.fit()`.

2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![logo](_media/talos_logo_bg.png)

## v1.2
## v1.2.3

> Hyperparameter Experiments with Tensorflow, PyTorch and Keras
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="app"></div>
<script>
window.$docsify = {
name: 'Talos 1.2',
name: 'Talos 1.2.3',
repo: 'https://github.com/autonomio/talos',
coverpage: true,
loadSidebar: true,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
URL = 'http://autonom.io'
LICENSE = 'MIT'
DOWNLOAD_URL = 'https://github.com/autonomio/talos/'
VERSION = '1.2.2'
VERSION = '1.2.3'


try:
Expand Down
2 changes: 1 addition & 1 deletion talos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
del commands, scan, model, metrics, key
del sub, keep_from_templates, template_sub, warnings

__version__ = "1.2.2"
__version__ = "1.2.3"
14 changes: 11 additions & 3 deletions talos/utils/power_draw_append.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
def power_draw_append(history, power_draw):

'''For appending the data from PowerDrawCallback to the history object
and allowing the data to be captured in the experiment log in Talos.'''
and allowing the data to be captured in the experiment log in Talos.
history | object | tf.keras model history object
power_draw | object | PowerDrawCallback object
'''

import numpy as np

joined = power_draw.log['epoch_begin'] + power_draw.log['epoch_end']
avg_watts = (np.array(joined)) / 2

history.history['watts_min'] = [min(joined)]
history.history['watts_max'] = [max(joined)]
history.history['seconds'] = [sum(power_draw.log['seconds'])]

# get average watts per epoc
epoch_begin = np.array(power_draw.log['epoch_begin'])
epoch_end = np.array(power_draw.log['epoch_end'])
avg_watts = (epoch_begin + epoch_end) / 2

watt_seconds = round(sum(avg_watts * np.array(power_draw.log['seconds'])), 2)
history.history['Ws'] = [watt_seconds]

Expand Down

0 comments on commit 17c1036

Please sign in to comment.