Hi,
I think adding a positive epsilon (e.g. 1e-10) to your matrix before applying the log will solve your problem. Check also that your matrix doesn’t have negative entries (normally the columns of your matrix will be the result of some softmax operation so this shouldn’t be a problem I guess)