Rle_encode() => Operands could not be broadcast together

EDIT: I think I’ve solved it by remembering to argmax/round my predictions to 0/1 before encoding.

I am trying to generate rle encodings for segmentation on a Kaggle submission, and I am having trouble making use of rle_encode().

My predictions are shape [1801, 5, 128, 800], where I have 1801 predictions of 5 classes each.

I thought I could create an rle string for each channel in each prediction, but one of the channels almost always seems to be off-by-one.

rles = rle_encode(preds[0][0])
ValueError: operands could not be broadcast together with shapes (43838,) (43839,) (43838,) 

rles = rle_encode(preds[0][1])
ValueError: operands could not be broadcast together with shapes (51200,) (51201,) (51200,) 

A few of them are not. This one returns a string.
rles = rle_encode(preds[4][0])

But not in each channel

rles = rle_encode(preds[4][1])
ValueError: operands could not be broadcast together with shapes (51200,) (51201,) (51200,) 

Can somebody offer an explanation for what I’m doing wrong? How should I generate my rle’s for each prediction?