From 9e3bdb3231d1fd237f51ce949eb31d0e948e6dbe Mon Sep 17 00:00:00 2001 From: Alexandros Metsai Date: Thu, 18 Apr 2019 06:33:18 -0700 Subject: [PATCH] Update module.py documentation. (#19347) Summary: Added the ">>>" python interpreter sign(three greater than symbols), so that the edited lines will appear as code, not comments/output, in the documentation. Normally, the interpreter would display "..." when expecting a block, but I'm not sure how this would work on the pytorch docs website. It seems that in other code examples the ">>>" sign is used as well, therefore I used with too. Pull Request resolved: https://github.com/pytorch/pytorch/pull/19347 Differential Revision: D14986154 Pulled By: soumith fbshipit-source-id: 8f4d07d71ff7777b46c459837f350eb0a1f17e84 --- torch/nn/modules/module.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/torch/nn/modules/module.py b/torch/nn/modules/module.py index 11c6a08..eb82b83 100644 --- a/torch/nn/modules/module.py +++ b/torch/nn/modules/module.py @@ -220,11 +220,10 @@ class Module(object): Example:: >>> def init_weights(m): - print(m) - if type(m) == nn.Linear: - m.weight.data.fill_(1.0) - print(m.weight) - + >>> print(m) + >>> if type(m) == nn.Linear: + >>> m.weight.data.fill_(1.0) + >>> print(m.weight) >>> net = nn.Sequential(nn.Linear(2, 2), nn.Linear(2, 2)) >>> net.apply(init_weights) Linear(in_features=2, out_features=2, bias=True) -- 2.7.4