Stacking binary mask frames in pytorch?
I am using Pytorch to attempt to create a 4-dimensional tensor (binary mask) using a "stack" of three-dimensional tensors that each hold binary masks.

The three-dimensional tensors have n instances of some segmented object in a binary mask that is 704 wide and 1080 high.

Lets lets say I have three of these 3-dimensional tensors. They are all size [n,704,1080], where n is the numbers of individual obejcts (and thus, individual binary masks) for the frame, 704 is height and 1080 is width:

t1.size = torch.Size([9, 704, 1280])
t2.size = torch.Size([12, 704, 1280])
t3.size = torch.Size([10, 704, 1280])


I want to create a stack of them by adding a fourth dimension, a. ie. [a, n, 704, 1280], where a is the original 3-dimensional tensor.

The goal is to have a 4-dimensional tensor that can hold the data of numerous 3-dimensional tensors. 

I have tried to torch.stack([t1, t2, t3]) but that does not work since the second dimension, n, is not consistent between all the tensors. 

How can I go about this since stack does not work?

You can't. 
All tensor dimensions except first must be the same.
Only way to do this, append dummy rows to first and third tensor to make them the same size (12,704,1280)

Or you can stack it in one 3 -dim tensor.
