multik
multik copied to clipboard
Add `pad` function
I would like to know how to pad using createAlignedNDArray
.
From my understanding this function takes a list of lists and makes every list the max length and pads the remaining with zeros or whatever value you want (for each dim).
Example:
Let P
be the size of each dims we want our final matrix to be with padding.
Let W
and H
be 2 sizes (different) that are less than P
.
For the sake of this example let's say we have W
< H
< P
.
Let a
be an mk array of shape (W, H)
.
Then applying createAlignedNDArray(a.toListD3(), 0.0)
would give us a matrix of shape (H, H)
padded with zeros.
While the name of the function seems correct, I'm interested in knowing if it's possible to use this function to transoform a
into a matrix of size (P, P)
instead.
Something like, we provide an mk array and can specify the desired padding for each dimensions.
See https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
If it's possible with createAlignedNDArray
then feel free to let me know.