You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: can't multiply sequence by non-int of type 'float' #63
Glad to see you're trying the algorithms described in the book. However, I would recommend adding more context to your questions: page? chapter? section? class? method?? what input values did you use (if any)? and even better, the actual script you used.
Based on the traceback, I assume you are in chapter 2, "Implementing a perceptron learning algorithm in Python". I implemented that one some time ago and it worked just fine. Therefore, my first assumption is that you have some typo in your script (we would only know if you provide your actual code).
The type of error you mentioned is typical of trying to multiply by a string (e.g., '1.0' * 1.). Check your code and post more questions (and more context) if required.
I agree with @Lijantropique : a bit more information would help, and I suspect a typo somewhere in the code. I just checked the code notebook and it seems to work fine with the most recent NumPy version.
and check if that works. Then, I would recommend comparing the Perceptron code in ch02.py with your script to find out any differences that may be causing your issue.
Activity
Lijantropique commentedon Aug 18, 2017
Hello,
Glad to see you're trying the algorithms described in the book. However, I would recommend adding more context to your questions: page? chapter? section? class? method?? what input values did you use (if any)? and even better, the actual script you used.
Based on the traceback, I assume you are in chapter 2, "Implementing a perceptron learning algorithm in Python". I implemented that one some time ago and it worked just fine. Therefore, my first assumption is that you have some typo in your script (we would only know if you provide your actual code).
The type of error you mentioned is typical of trying to multiply by a string (e.g., '1.0' * 1.). Check your code and post more questions (and more context) if required.
Cheers!
rasbt commentedon Aug 18, 2017
I agree with @Lijantropique : a bit more information would help, and I suspect a typo somewhere in the code. I just checked the code notebook and it seems to work fine with the most recent NumPy version.
If you don't like to use Jupyter Notebooks, you can also run the code from https://github.com/rasbt/python-machine-learning-book/blob/master/code/optional-py-scripts/ch02.py
I.e., in your terminal, you can run
and check if that works. Then, I would recommend comparing the
Perceptroncode inch02.pywith your script to find out any differences that may be causing your issue.