Skip to content
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions smdebug/trials/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,14 @@ def tensors(self, *, step=None, mode=ModeKeys.GLOBAL, regex=None, collection=Non

if regex is None and collection is None:
return sorted(list(ts))
elif regex is not None and collection is not None:
raise ValueError("Only one of `regex` or `collection` can be passed " "to this method")
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird string formatting going on here. Combine the two quotes in the middle.

else:
xs = set()
if regex is not None:
xs.update(self._tensors_matching_regex(regex))
if collection is not None:
collection_tensors_saved = set(self._tensors.keys()).intersection(
self._tensors_in_collection(collection)
)
xs.update(collection_tensors_saved)

return sorted(list(ts.intersection(xs)))
xs = set(self._tensors.keys()).intersection(self._tensors_in_collection(collection))
else:
xs = self._tensors_matching_regex(regex)
return sorted(list(ts.intersection(xs)))

def _tensors_for_step(self, step, mode=ModeKeys.GLOBAL) -> list:
step = self._mode_to_global[mode][step] if mode != ModeKeys.GLOBAL else step
Expand Down