【发布时间】:2019-03-10 10:25:37
【问题描述】:
我在 google colab 的单个单元格中运行以下代码 sn-p:
%debug
# Create tensors of shape (10, 3) and (10, 2).
x = torch.randn(10, 3)
y = torch.randn(10, 2)
# Build a fully connected layer.
linear = nn.Linear(3, 2)
print ('w: ', linear.weight)
print ('b: ', linear.bias)
我希望调试一段代码(逐行逐行执行)以了解发生了什么。我希望进入函数 nn.Linear。
但是,当我单步执行时,它根本没有进入函数。有没有办法逐行遍历 nn.Linear?另外,我究竟如何在 nn.Linear 中设置断点?此外,我还希望逐行了解 sn-p。但是,如图所示,step 命令会自动单步执行并执行 print 语句。
【问题讨论】:
标签: python deep-learning pytorch tensor google-colaboratory