c of shape (1, 300) not acceptable as a color sequence for x with size 300, y with size 300

该错误来自于吴恩达深度学习课程第二课第一周的第一个assignment。

纠正方法:

# 找到reg_utils.py中的load_2D_dataset函数,将
plt.scatter(train_X[0, :], train_X[1, :], c=train_Y, s=40, cmap=plt.cm.Spectral);
# 修改为
plt.scatter(train_X[0, :], train_X[1, :], c=np.squeeze(train_Y), s=40, cmap=plt.cm.Spectral);

# 找到init_utils.py中的plot_decision_boundary函数,并将
plt.scatter(X[0, :], X[1, :], c= y , cmap=plt.cm.Spectral)
# 改为
plt.scatter(X[0, :], X[1, :], c=np.squeeze(y), cmap=plt.cm.Spectral)

restart kernel并运行即可。

猜你喜欢

转载自blog.csdn.net/chongchong247619000/article/details/83217006
300
今日推荐