Skip to content

Commit 37e526e

Browse files
karandwivedi42facebook-github-bot
authored andcommitted
Better print of nn Containers (#8939)
Summary: Fix #8900 Waiting on #8463 1. Remove extra Line 2. ... Closes #8939 Reviewed By: soumith Differential Revision: D8687730 Pulled By: ezyang fbshipit-source-id: 81c57a03683875704d537cb4585b11838f70df56
1 parent 512c49e commit 37e526e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

torch/nn/modules/container.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,12 @@ def extend(self, parameters):
268268
return self
269269

270270
def extra_repr(self):
271-
tmpstr = ''
271+
child_lines = []
272272
for k, p in self._parameters.items():
273273
size_str = 'x'.join(str(size) for size in p.size())
274274
device_str = '' if not p.is_cuda else ' (GPU {})'.format(p.get_device())
275275
parastr = 'Parameter containing: [{} of size {}{}]'.format(
276276
torch.typename(p.data), size_str, device_str)
277-
tmpstr = tmpstr + ' (' + k + '): ' + parastr + '\n'
277+
child_lines.append(' (' + k + '): ' + parastr)
278+
tmpstr = '\n'.join(child_lines)
278279
return tmpstr

0 commit comments

Comments
 (0)