Jan-19-2017, 02:01 AM
This should be simple.
I am using NumPy's ndarray, and taking the shape() of the 1st element like this:X.shape[0]. As expected, this is an integer that evaluates to 100.
When I try to add that to integer literal, I get a type error.
I am using NumPy's ndarray, and taking the shape() of the 1st element like this:X.shape[0]. As expected, this is an integer that evaluates to 100.
When I try to add that to integer literal, I get a type error.
type(X.shape[0]) Out[87]: int type(1+X.shape[0]) Out[88]: int type(X) Out[89]: numpy.ndarray
Error:Traceback (most recent call last):
File "C:\Users\WB\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-86-b745a6cdd684>", line 1, in <module>
ppn.fit(X,y)
File "C:\Users\wb\PycharmProjects\untitled8\Perceptron.py", line 9, in fit
zz=1 + X.shape[0]
TypeError: unsupported operand type(s) for +: 'int' and 'tuple'
As you can see from the trace, I should be adding two integers. Why does it think one of them is a tuple?