The error seems to be raised by numpy in:
np.array(egs.values())

Based on the error message it seems that egs.values() might return objects with variable shapes or any other objects which numpy cannot transform to an array.
Could you print this object and check what is stored in it?