1. 程式人生 > >pytorch資料型別報錯解決方案:

pytorch資料型別報錯解決方案:

pytorch報錯:
RuntimeError: Expected object of type Variable[torch.LongTensor] but found type Variable[torch.cuda.ByteTensor] for argument #1 ‘argument1’

解決方法:

pytorch框架在儲存labels時,採用LongTensor來儲存,所以在一開始dataset返回label時,就要返回與LongTensor對應的資料型別,即numpy.int64