How to add Padding/Zero Rows to OneHotArray in Flux

The input data to my model is 1-hot encoded, and of different lengths, and it is 3D. Therefore it must be represented with a sparse datatype and padded to the same length.

Currently, I am using multidimensional Flux OneHotArrays and I am wondering if there is a way to pad and mask them with zero columns. Currently, I do not see how I can add a zero row to a Flux OneHotArray. I tried using SparseMatrixCSC, which allows me to add zero rows, but it can only be in 2D, not 3D.

Please let me know how I should go about padding (and masking if possible) a 3D one-hot matrix with zero columns.



If you pad a one-hot array, it’s no longer one-hot :stuck_out_tongue:. I think it would be best to describe your use case and data first, because I’m not aware of many datasets which a) have 3D samples (i.e. pre-batching), b) have ragged data, and c) can’t crop/resize that data so that it’s not ragged.