Skip to content

Conversation

NihalHarish
Copy link
Contributor

Description of changes:

  • Implements save_tensor api for pytorch and mxnet
  • Adds tests

Style and formatting:

I have run pre-commit install to ensure that auto-formatting happens with every commit.

Issue number, if available

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Jul 22, 2020

Codecov Report

Merging #291 into save_inputs will decrease coverage by 4.49%.
The diff coverage is 46.66%.

Impacted file tree graph

@@               Coverage Diff               @@
##           save_inputs     #291      +/-   ##
===============================================
- Coverage        84.40%   79.91%   -4.50%     
===============================================
  Files               86       86              
  Lines             6336     6363      +27     
===============================================
- Hits              5348     5085     -263     
- Misses             988     1278     +290     
Impacted Files Coverage Δ
smdebug/mxnet/hook.py 0.00% <0.00%> (-92.80%) ⬇️
smdebug/mxnet/utils.py 0.00% <0.00%> (-61.91%) ⬇️
smdebug/core/hook.py 87.10% <33.33%> (-6.53%) ⬇️
smdebug/pytorch/hook.py 80.32% <50.00%> (-0.51%) ⬇️
smdebug/tensorflow/keras.py 83.92% <57.14%> (-0.07%) ⬇️
smdebug/core/utils.py 83.00% <66.66%> (-0.50%) ⬇️
smdebug/pytorch/utils.py 43.58% <100.00%> (+3.04%) ⬆️
smdebug/mxnet/singleton_utils.py 0.00% <0.00%> (-100.00%) ⬇️
smdebug/mxnet/__init__.py 16.66% <0.00%> (-83.34%) ⬇️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ca2942...4377bfe. Read the comment docs.

@@ -0,0 +1,209 @@
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test:
numpy array.
regular array

@NihalHarish NihalHarish changed the base branch from master to save_inputs July 23, 2020 03:39
@NihalHarish NihalHarish changed the base branch from save_inputs to master July 23, 2020 05:30
@NihalHarish NihalHarish changed the base branch from master to save_inputs July 23, 2020 20:12
self._save_tensor(tensor_name, tensor_value, collection_names)
self._save_tensor_to_file(tensor_name, tensor_value, collection_names)

def _save_tensor(self, tensor_name, tensor_value, collections_to_write):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a conflict for the name _save_tensor() ? or are you changing this to avoid confusion with hook.save_tensor()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm changing this name to avoid confusion

model.train()
# for batch_idx, (data, target) in enumerate(train_loader):
if save_custom_tensor:
hook.save_tensor("custom_tensor", torch.tensor([[1.0, -1.0], [1.0, -1.0]]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add save_tensor calls at different points in the training loop. before, during, after - to check if it is getting written at the correct step. similar to save_scalar

hook.save_custom_tensor("custom_tensor_3", t3, include_collections)
hook.save_tensor("custom_tensor_1", t1, include_collections)
hook.save_tensor("custom_tensor_2", t2, include_collections)
hook.save_tensor("custom_tensor_3", t3, include_collections)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save_tensor after fit() too? how are we verifying if the tensor is written at the right step and correct mode?

@NihalHarish NihalHarish changed the base branch from save_inputs to master July 27, 2020 19:29
@NihalHarish NihalHarish changed the base branch from master to save_inputs July 27, 2020 23:31
@NihalHarish NihalHarish merged commit 2df55e0 into save_inputs Jul 28, 2020
@NihalHarish NihalHarish deleted the save_tensor_test branch July 28, 2020 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants