Ok I think I solved it. In the except: clause of the getitem() function, I replaced
target = np.zeros((196, 196))
with
target = np.array(np.zeros((196, 196)), dtype='uint')
This solved the error. Though I’m not very sure how, maybe because earlier torch.cat() was trying to concatenate doubleTensor (from except:) with ByteTensor.