Spyder crashes upon typing `net(` in editor
See original GitHub issueDescription of your problem
I execute the code below. Then try to type net(
and Spyder crashes.
What steps will reproduce the problem? Execute this code:
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
# 1 input image channel, 6 output channels, 5x5 square convolution
# kernel
self.conv1 = nn.Conv2d(1, 6, 5) # Takes 4D input: nSamples + nChannels x Height x Width
self.conv2 = nn.Conv2d(6, 16, 5)
# an affine operation: y = Wx + b
self.fc1 = nn.Linear(16 * 5 * 5, 120)
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 10)
def forward(self, x):
# Max pooling over a (2, 2) window
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
# If the size is a square you can only specify a single number
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
x = x.view(-1, self.num_flat_features(x))
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
def num_flat_features(self, x):
size = x.size()[1:] # all dimensions except the batch dimension
num_features = 1
for s in size:
num_features *= s
return num_features
net = Net()
print(net)
*Code comes from PyTorch Tutorial webpage (http://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html)
I saved this file as YSTest.py
What is the expected output? What do you see instead?
Expected output is word net()
appearing in editor. The net
object is instance of Net class, so there should be no reason why I am unable to get this to work properly.
Please provide any additional information below
Often, but not always (and this is hard to replicate, but very annoying) Spyder will crash if I type net(
into the YSTest.py file BEFORE executing a single line of code. Curiously, this problem manifests only if net(
is typed in the YSTest.py file that has the code above. Typing net(
in a new Python file adjacent to the YSTest.py file results in no error (with or without packages loaded). In fact, if I execute the code above and type net(
in a new python file in Spyder, there is no error. Similarly, there is no error with typing net(
in the IPython kernel (it even brings up the expected in-line documentation support instantly!)
This led me to believe the YSTest.py file is corrupted, so I made new such file in a clean directory by manually typing all commands above in. Problem persists. Running spyder --reset
and restarting my computer did not resolve the issue either…
Versions and main components
- Spyder Version: 3.2.4
- Python Version: 2.7
- Qt Version: 5.6.2
- PyQt Version: 5.6
- Operating system: Ubuntu 14.04
Dependencies
Please go to the menu entry Help > Optional Dependencies
(or
Help > Dependencies
), press the button Copy to clipboard
and paste the contents below:
IPython >=4.0;<6.0: 5.4.1 (OK) cython >=0.21 : 0.26.1 (OK) jedi >=0.9.0 : 0.10.2 (OK) nbconvert >=4.0 : 5.3.1 (OK) numpy >=1.7 : 1.13.3 (OK) pandas >=0.13.1 : 0.20.3 (OK) psutil >=0.3 : 5.4.0 (OK) pycodestyle >=2.3 : 2.3.1 (OK) pyflakes >=0.5.0 : 1.6.0 (OK) pygments >=2.0 : 2.2.0 (OK) pylint >=0.25 : 1.7.4 (OK) qtconsole >=4.2.0 : 4.3.1 (OK) rope >=0.9.4 : 0.10.5 (OK) sphinx >=0.6.6 : 1.6.3 (OK) sympy >=0.7.3 : 1.1.1 (OK)
Additional info:
PyTorch version: 0.3.0.post4
*Installed PyTorch via Anaconda for Python 2.7 as per official install instructions (http://pytorch.org/):
conda install pytorch torchvision -c pytorch
for PyTorch without CUDA
Issue Analytics
- State:
- Created 6 years ago
- Comments:21 (12 by maintainers)
Top GitHub Comments
Tried this today. I execute the code above, no errors; terminal shows bunch of outputs that show everything is okay (not posting here, bc. very long; both
jedi
andrope
initialize as expected without errors). Program ends, and I click to new empty line at end of program; Jedi is initialized without problems (first line in terminal output below). I then typenet(
and program crashes. Below, find rest of terminal output. Seems like problem is withrope
ortorch.nn.modules.module.Module modul
Let me know if there are others things you’d like me to explore.
@ysumath1 I can now recreate it by typing
net(
twice! Thank you for your diligence in helping us work on this. Next step for me is to now find the root cause. 😃