How to load huge 1-dimension sparse array?

Hi, I have a huge 1-dimension sparse array (e.g. [0,0,…,0,1,0,0,…,0]) to feed into PyTorch for training. Is there an efficient way to define the input?

I have looked at the torch.sparse, but that seems is for 2-D.

Besides, the targets are also sparse array, is there an efficient way to compare the output of the training and the target?

You can use sparse arrays with 1d as well. Subtracting sparse array should work.

Best regards

Thomas