IndexError:Dimension out of range(expected to be in range of [-1,0],but got 1)

跑一個ocr的代碼出現上述錯誤,解決方法: 1.設置batch_size和num_epochs能整除,即num_epochs/batch_size的值是一個正整數。 2.在DataLoader函數中,設置drop_last=True,如下圖所示:
相關文章
相關標籤/搜索