cs231n / cs231n.github.io

Public facing notes page
MIT License
10.12k stars 4.06k forks source link

Error in assignment1 features notebook #204

Closed tobyatgithub closed 1 year ago

tobyatgithub commented 5 years ago

Error happened when I tried to call the given extract_features function...Very confused by why this happened. (All previous notebooks worked perfectly well.) Any help is appreciated!

Error message:

TypeError Traceback (most recent call last)

in () 3 num_color_bins = 10 # Number of bins in the color histogram 4 feature_fns = [hog_feature, lambda img: color_histogram_hsv(img, nbin=num_color_bins)] ----> 5 X_train_feats = extract_features(X_train, feature_fns, verbose=True) 6 X_val_feats = extract_features(X_val, feature_fns) 7 X_test_feats = extract_features(X_test, feature_fns) ~/Documents/edX/Stanford_231n/CS231n/assignment1/cs231n/features.py in extract_features(imgs, feature_fns, verbose) 33 first_image_features = [] 34 for feature_fn in feature_fns: ---> 35 feats = feature_fn(imgs[0].squeeze()) 36 assert len(feats.shape) == 1, 'Feature functions must be one-dimensional' 37 feature_dims.append(feats.size) ~/Documents/edX/Stanford_231n/CS231n/assignment1/cs231n/features.py in hog_feature(im) 119 cond2 = temp_ori > 0 120 temp_mag = np.where(cond2, grad_mag, 0) --> 121 orientation_histogram[:,:,i] = uniform_filter(temp_mag, size=(cx, cy))[cx/2::cx, cy/2::cy].T 122 123 return orientation_histogram.ravel() TypeError: slice indices must be integers or None or have an __index__ method ----End Error message----- ----system version:------ print(sys.version) = 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
Amirgav-zz commented 5 years ago

You have an answer here:

https://github.com/cs231n/cs231n.github.io/issues/177