我是在写cs231n的assignment1的时候,遇到这个错误的具体发生错误的代码如下:
# Subsample the data for more efficient code execution in this exercise
num_training = 5000
mask = list(range(num_training))
X_train = X_train[mask]
y_train = y_train[mask]
num_test = 500
mask = list(range(num_test))
X_test = X_test[mask]
y_test = y_test[mask]
提示说错误在这个地方:
mask = list(range(num_training))
于是我参考:https://blog.csdn.net/happy_wealthy/article/details/105869675?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param
里面的方法。
在代码前面加上了两句:
print(list)
del(list)
结果发现好想list这个变量名之前被占了,所以这两句话写完之后,程序就不再报错了。