# How to add Padding/Zero Rows to OneHotArray in Flux

**URL:** <https://discourse.julialang.org/t/how-to-add-padding-zero-rows-to-onehotarray-in-flux/83239>\
**Category:** General Usage\
**Tags:** flux, sparse\
**Created:** [June 23, 2022, 2:12pm UTC](https://discourse.julialang.org/t/how-to-add-padding-zero-rows-to-onehotarray-in-flux/83239 "2022-06-23T14:12:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jack\_N](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jack_n/32/37265_2.png) [@Jack\_N](https://discourse.julialang.org/u/Jack_N)\
**Post date:** [June 23, 2022, 2:12pm UTC](https://discourse.julialang.org/t/how-to-add-padding-zero-rows-to-onehotarray-in-flux/83239/1 "2022-06-23T14:12:40Z")

</div>

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.

Thanks,

Jack

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [June 28, 2022, 10:42pm UTC](https://discourse.julialang.org/t/how-to-add-padding-zero-rows-to-onehotarray-in-flux/83239/2 "2022-06-28T22:42:23Z")

</div>

If you pad a one-hot array, it’s no longer one-hot 😛. 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.
