RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target'

在用pytorch進行深度神經網絡訓練時,出現以下問題,特做記錄 這個錯誤是說需要的數據類型是long而我的數據類型是float,所以需要進行數據類型轉化 在pytorch中數據轉化有專屬自己的用法,即data=data.long() 所以在代碼中做了如下修改: cond_op_truth_var = cond_op_truth_var.long() 問題解決
相關文章
相關標籤/搜索