matlab: exp(X) gives inf even though exp(max(X)) does not -


[edit: The whole thing is a very simple solution: the matrix has a single datatype instead of the default double Used]

I have seen some bizarre (I think) behavior matlab and wonder what is causing this. I have 10000x500 matrix M <-0>

  to min (min (m)) -226.9723 to max (max) (m)) = 92.8173  

and

  exp (-227) = 2.6011e-99 exp (93) = 2.4512e + 40  

But if I extend the entire matrix, this matrix There are INR values ​​in:

  ii = isinf (exp (m)); How does the matlab store the values ​​in the matrix so that different elements can give different results while performing the same operation on the operation matrix? Self?  

Come expM = exp (m); XP (M) (1) == XPM (1); % May be wrong, which makes me wonder.

I know that I have to change the algorithm because high intrusion will give inappropriate results, even if I can escape the inferior values. It is in a formula for an artificial neural network calculation:

  yoga (logs (1 + APP (numcases, 1) * b_h + data * w_vh), 2); < So my plan is to split it into two cases, where the exponent is small, calculate the above, I estimate the higher values ​​ 
  log ( 1 + APP (with (numcases, 1) * b_h + data * w_vh)  

with

  ones (numcases, 1) * b_h + data * W_vh  

Is it fair? My argument is that

  logs (1 + e Xp (x)) ≈ log (expansion) Xx for BTW, maximum max max (max) max (M) in addition to maximizing matrix max. Is there a better way to get the element? 

OK, I got an error: My matrix was of one type , But when I copied the value a new variable that would definitely be double with a second maximum value. Answer this way so that the questions remain unanswered. Thanks for the tips, I found the reason when trying to make a repro-case :)


Comments