Issue
I am new to tf, and during reading a model code, I noticed it used 1), but most document I can find are using 2) and 3). So what is the tensorflow.python
library used for,seems it is not in official document? And what is the relation between 1 to 2,3?
- from tensorflow.python.training.adagrad import AdagradOptimizer
- from tf.compat.v1.train import AdagradOptimizer
- from tf.keras.optimizers import Adagrad
Solution
Basically:
tensorflow.python
is essentially "internal" code and not part of the public API. You should never use anything in there directly. It may work, but it can also lead to instabilities, break completely if you update your TF version, etc.- This is a hold-over from old TF versions, before Keras was tightly integrated with it. IMHO you should just forget that this exists and they should have just removed it completely. This would be used with the outdated layers interface (
tf.compat.v1.layers
). - This is what you should use if using
tf.keras
(models and/or layers) and should be your go-to interface (not necessarily Adagrad specifically, but all the optimizers intf.keras.optimizers
).
Answered By - xdurch0
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.