-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
想问下使用from tensorflow.python.kears import xxx 而非使用tensorflow.kears的原因是什么? #510
Comments
另外我发现,使用
与使用
得到的AUC的评估值也会有差异,一样的数据,第一个为0.66,第二个为0.72,实际上的AUC确实是0.66。所以 python version 3.7.16 |
tensorflow.python.kears是新版本的写法,尤其是tensorflow version2.9之后,去看本地库是没有tensorflow.kears这个包的。 |
看到tf社区TensorFlow Team的 @qlzh727 有回复说:
所以应该不要直接使用 |
the proper imort of keras is
|
For the actual keras code, it stays in |
我所获的的信息也是尽量不要使用
如 https://github.com/shenweichen/DeepCTR/blob/master/deepctr/models/deepfm.py |
这个有官方的说明吗? |
I agree, but deepctr uses |
I guess it is a compatibility problem. DeepCTR want to compatible with both tf 1.x and tf 2.x. Under tf 1.x (such as 1.4), using |
@qlzh727 So, is there any best practice to handle those problem for projects which need to compatible with both tf 1.x and tf 2.x ? |
tf.keras was always the public API to access. For TF 1.4, I don't think keras was part of the TF API at the time, so you can't even access tensorflow.python.keras at the time. If you need the last TF 1.X (eg tf.1.15), you can still use |
并不是,tensorflow.python.keras不是正规的写法 |
It will raise error using tensorflow.python.keras now, tensorflow/tensorflow#61215 |
现在tensorflow 2.14 必须要将tensorflow.python.keras换成tensorflow.keras 否则会报错;另外tensorflow和keras这两个包的关系真是有点混乱。。。 |
问这个问题的起因是我在
model.compile
时使用了tensorflow.kears
的方法:导致后续使用load_model时报错,无论是使用
tensorflow.python.keras.models.load_model
或是tensorflow.keras.models.load_model
都会报错:AttributeError: 'AUC' object has no attribute '_serialized_attributes'
一通查找,出错的原因应该就是
tensorflow.python.kears
与tensorflow.kears
混淆使用的问题。报错的问题我解决了,将
from tensorflow import kears
改为deepCTR中一致的from tensorflow.python import kears
即可。我的疑问是,为什么要使用
tensorflow.python.kears import
而非使用tensorflow.kears
?tensorflow.python.的相关资料能查到的不多,我看到的有以下这个:
————————————————————
Anything under tf.python. is private, intended for development only, rather than for public use.
Importing from tensorflow.python or any other modules (including import tensorflow_core...) is not supported, and can break unannounced.
So, it is suggested not to use anything with tf.python.*.
————————————————————
按照这个说法,是不建议使用的,所以想问问,以上这个说法正确吗(上面这个说法是3年前的一个回答,所以准确性我也无法确保)?以及deepCTR中使用tf.python.*的原因是什么?
The text was updated successfully, but these errors were encountered: