Could you check, if any parameters are containing invalid values (NaN or Inf), as this should never happen. If not, then could you check the forward activations for invalid values (in particular for overflows) during the forward pass creating the NaN output?