udacity / robotics-nanodegree-issues

Public waffleboard to track Robotics Nanodegree Issues
2 stars 0 forks source link

Object Recognition code has syntax error #186

Closed jazzdman closed 6 years ago

jazzdman commented 7 years ago

Perception Section Lesson 5 Object Recognition Part 17 Object Recognition

Make the prediction, retrieve the label for the result

and add it to detected_objects_labels list

prediction = clf.predict(scaler.transform(feature.reshape(1,-1)))

This line should be :

prediction = clf.predict(scaler.transform(feature.reshape( (1,-1) )))

The parameter passed to reshape should be a tuple:

https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.reshape.html

sahiljuneja commented 7 years ago

Both are correct. You can try testing that out with a smaller array and compare the output of the two.

In the above case you are defining it as feature.reshape(new_shape) and not as np.reshape(feature, new_shape).

For the latter, new_shape has to be a tuple. For the former, you need not pass the dimensions as a tuple. Both are correct definitions.

I tested both locally right now in the VM and it seems to work. And I know students haven't faced this problem before. If there's a specific error message that you could share, then we can check that out.