Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

python - What if I want to continue my code when this problem come out? RuntimeError: Optimal parameters not found

My code is too long and I don't want to solve this error, because of the flaws of original data.
The error is:
RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 50000.
This error come out when iterations = maxfev. What I want to do is: when the iterations = maxfev, don't shut down the code, but to continue operating next pack of data. For example:

if raise RuntimeError :
   data = data
else:
   data = data-1

Something like that.
I just don't want the program to stop.
I don't know did I say clearly? Ask me if you need any details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can do it like this.

try:
    somecode
except RuntimeError as err:
    print('error')
    data = data
    raise err
else:
    print('no error')
    data = data - 1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...