rasbt / deeplearning-models

A collection of various deep learning architectures, models, and tips

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NameError: name 'custom_where' is not defined

Totoro-wen opened this issue · comments

Hello,I discovered the following problem in pycharm
deeplearning-models/pytorch_ipynb/basic-ml/perceptron.ipynb

Traceback (most recent call last):
  File "/home/aibc/Desktop/DL/pytorch_ML/traditional_ml/preceptron/preceptron.py", line 99, in <module>
    ppn.train(X_train_tensor, y_train_tensor, epochs=5)
  File "/home/aibc/Desktop/DL/pytorch_ML/traditional_ml/preceptron/preceptron.py", line 84, in train
    errors = self.backward(x[i].view(1, self.num_features), y[i]).view(-1)
  File "/home/aibc/Desktop/DL/pytorch_ML/traditional_ml/preceptron/preceptron.py", line 75, in backward
    predictions = self.forward(x)
  File "/home/aibc/Desktop/DL/pytorch_ML/traditional_ml/preceptron/preceptron.py", line 71, in forward
    predictions = custom_where(linear > 0., 1, 0).float()
NameError: name 'custom_where' is not defined

I looked up the definition of the function, but nothing came of it.
I hope you can help me. Thank you

I don't have PyCharm and can't verify, but the notebook is working ok in Jupyter Lab. Maybe PyCharm is not parsing the notebook correctly. The function is defined in cell 5 (see screenshot below).

Screen Shot 2019-09-12 at 8 52 06 PM