-
Notifications
You must be signed in to change notification settings - Fork 83
Implement Save Tensor For Mxnet and Pytorch #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
27cbc8c
save custom tensors
NihalHarish 7db230d
PR comments
NihalHarish 22fe114
pr comments
NihalHarish 0aab04d
validate in tf2
NihalHarish 2b847b4
retrigger CI
NihalHarish 2b21e02
clear dicts after loop
NihalHarish 69282f7
nit
NihalHarish 55120ce
save custom api
NihalHarish 5383d8e
retrigger CI
NihalHarish 4a80118
save tensors
NihalHarish da3e711
pytorch assert
NihalHarish 4377bfe
merge
NihalHarish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
SMDEBUG_GRADIENTS_KEY = "smdebug_gradients" | ||
SMDEBUG_LAYER_OUTPUTS_KEY = "smdebug_layer_outputs" | ||
SMDEBUG_PREFIX = "smdebug_" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Standard Library | ||
import shutil | ||
from datetime import datetime | ||
|
||
# First Party | ||
from smdebug import SaveConfig | ||
from smdebug.core.collection import CollectionKeys | ||
from smdebug.mxnet.hook import Hook as t_hook | ||
from smdebug.trials import create_trial | ||
|
||
# Local | ||
from .mnist_gluon_model import run_mnist_gluon_model | ||
|
||
|
||
def test_hook(): | ||
save_config = SaveConfig(save_steps=[0, 1, 2, 3]) | ||
run_id = "trial_" + datetime.now().strftime("%Y%m%d-%H%M%S%f") | ||
out_dir = "/tmp/newlogsRunTest/" + run_id | ||
hook = t_hook(out_dir=out_dir, save_config=save_config) | ||
run_mnist_gluon_model( | ||
hook=hook, | ||
num_steps_train=10, | ||
num_steps_eval=10, | ||
register_to_loss_block=True, | ||
save_custom_tensor=True, | ||
) | ||
trial = create_trial(out_dir) | ||
custom_tensors = trial.tensor_names(collection=CollectionKeys.DEFAULT) | ||
all_tensors = trial.tensor_names() | ||
assert len(custom_tensors) == 2 | ||
assert len(all_tensors) == 4 | ||
shutil.rmtree(out_dir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Standard Library | ||
import shutil | ||
from datetime import datetime | ||
|
||
# Third Party | ||
import torch | ||
import torch.optim as optim | ||
|
||
# First Party | ||
from smdebug.core.collection import CollectionKeys | ||
from smdebug.pytorch import SaveConfig | ||
from smdebug.pytorch.hook import Hook as t_hook | ||
from smdebug.trials import create_trial | ||
|
||
# Local | ||
from .utils import Net, train | ||
|
||
|
||
def test_hook(): | ||
vandanavk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
run_id = "trial_" + datetime.now().strftime("%Y%m%d-%H%M%S%f") | ||
out_dir = "/tmp/" + run_id | ||
hook = t_hook( | ||
out_dir=out_dir, | ||
save_config=SaveConfig(save_steps=[0, 1, 2, 3]), | ||
include_collections=["relu_activations"], | ||
) | ||
|
||
model = Net().to(torch.device("cpu")) | ||
hook.register_module(model) | ||
optimizer = optim.SGD(model.parameters(), lr=0.001, momentum=0.9) | ||
train(model, hook, torch.device("cpu"), optimizer, num_steps=10, save_custom_tensor=True) | ||
trial = create_trial(out_dir) | ||
custom_tensors = trial.tensor_names(collection=CollectionKeys.DEFAULT) | ||
assert len(custom_tensors) == 4 | ||
shutil.rmtree(out_dir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.