Open AmirNoori68 opened 1 year ago
@AmirNoori68 you can just add ScipyOptimizerInterface
to helper.py file from external_optimizer.py
Then import from helper import ScipyOptimizerInterface
and replace tf.contrib.opt.ScipyOptimizerInterface
to ScipyOptimizerInterface
@vldud-off Works fine. Thanks!
where is helper.py and how to add ScipyOptimizerInterface ?
where is helper.py and how to add ScipyOptimizerInterface ?
First, download https://github.com/tensorflow/tensorflow/blob/876fc8dc4f40c75914dbfcb0a809feaf81be7412/tensorflow/contrib/opt/python/training/external_optimizer.py, give it a name like "helper.py" and put it in the main folder.
next, add "from helper import ScipyOptimizerInterface" to the main code.
Finally, replace the current Scipy optimizer ("tf.contrib.opt.ScipyOptimizerInterface") with the following code: self.optimizer = ScipyOptimizerInterface(self.loss, method = 'L-BFGS-B', options = {'maxiter': 50000, 'maxfun': 50000, 'maxcor': 50, 'maxls': 50, 'ftol' : 1.0 * np.finfo(float).eps})
Hi, This code is based on the "TF1.X". There is no way to get "TF1.X" anymore on either Google colab or Jupyter. Just the "TF1.X" parts can be updated to "TF2.X" by two following lines: import tensorflow.compat.v1 as tf tf.disable_v2_behavior()
But I still get error in "self.optimizer = tf.contrib.opt.ScipyOptimizerInterface()." It says, "AttributeError: module 'tensorflow.compat.v1' has no attribute 'contrib' ." The reason is that "tf.contrib" is not changed, but moved from tensorflow! Can anyone help to solve this problem?