Convert DMatrix to numpy/torch

I am trying to implement a custom objective function with pytorch.
When I use the sklearn API the memory grows horribly large until the thread crashes (RAM and pagefile combine I have over 90GB). When I use the training API I can convert the data to DMatrix.
Now when implemting my custom objective function, it receives the predictions as a DMatrix and not an array. How can I convert the predictions to a numpy array or even better a torch tensor so I can calculate the loss?

Thx & Best,

1 Like