logo
Loading...

出現The truth value of an array with more than one element is ambiguous?錯誤 - Cupoy

請問一下為什麼會出現這個錯誤? 查了資料還是不清楚這個錯誤代表什麼意思?

ml100-4

出現The truth value of an array with more than one element is ambiguous?錯誤

2020/06/17 下午 02:59
機器學習共學討論版
吳育任
觀看數:10
回答數:2
收藏數:0
ml100-4

請問一下為什麼會出現這個錯誤? 查了資料還是不清楚這個錯誤代表什麼意思?![擷取.PNG](http://kwassistfile.cupoy.com/00000172C10E64E60000000B6375706F795F72656C656173655155455354/1592291855262/large)![擷取2.PNG](http://kwassistfile.cupoy.com/00000172C10E64E60000000B6375706F795F72656C656173655155455354/1592291855263/large)

回答列表

  • 2020/06/18 上午 01:03
    Jeffrey
    贊同數:1
    不贊同數:0
    留言數:2

    x = np.arange(-10,10, 0.01)  --> x = [ -0.99 ~ 9.99]  是一個包含 >0, 跟 <0 的 list,

    丟到 ReLu(x), 無法執行

    所以, 應該改成:


    for i in np.arange(-10,10,0.01):

       x = i

       plt.plot(x, ReLu(x),'r+')

    plt.grid()

    plt.show()

  • 2020/06/18 下午 11:50
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:0

    嗨,原因是你的 X 是一個 Array,X > 0 也會是一個 Boolean Array,會導致 if 條件失敗。


    如果這個回答對你有幫助請主動點選「有幫助」的按鈕,也可以追蹤我的GITHUB帳號。若還有問題的話,也歡迎繼續再追問或者把你理解的部分整理上來,我都會提供你 Review 和 Feedback 😃😃😃