'OverflowError: (34, 'Result too large') when performing operation on simple numbers
I am trying to use the tanH function in my code but I can't perform it on simple numbers ex. 74.83 because it always says "OverflorError: (34, 'Result too large')". There is not much code that is relevant to the problem, here it is
nv += (p_n * w)
nv = round(nv, 2)
if n == len(in)-1:
nv = tanh_activate(nv) #error in this function
else:
nv = relu_activate(nv)
and
def tanh_activate(x):
er = round(e,4) #e from cmath library
return round(pow(er,x)-pow(round(er,-x)) / (pow(er,x)+pow(er,-x)),2)
how do I make the function avoid returning a float that is larger than the float limit?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
