keras 和 tf.keras 有什么区别? [英] What is the difference between keras and tf.keras?
问题描述
我正在学习 TensorFlow 和 Keras.我想试试 https://www.amazon.com/Deep-Learning-Python-Francois-Chollet/dp/1617294438/,而且好像是用Keras写的.
I'm learning TensorFlow and Keras. I'd like to try https://www.amazon.com/Deep-Learning-Python-Francois-Chollet/dp/1617294438/, and it seems to be written in Keras.
将代码转换为 tf.keras
是否相当简单?
Would it be fairly straightforward to convert code to tf.keras
?
我对代码的可移植性更感兴趣,而不是两者之间的真正区别.
I'm not more interested in the portability of the code, rather than the true difference between the two.
推荐答案
在这一点上,tensorflow 几乎完全采用了 keras API 并且有充分的理由 - 它简单、易于使用且易于学习,而纯粹"tensorflow 带有很多样板代码.是的,您可以毫无问题地使用 tf.keras,尽管您可能需要在代码中重新处理导入.例如
At this point tensorflow has pretty much entirely adopted the keras API and for a good reason - it's simple, easy to use and easy to learn, whereas "pure" tensorflow comes with a lot of boilerplate code. And yes, you can use tf.keras without any issues, though you might have to re-work your imports in the code. For instance
from keras.layers.pooling import MaxPooling2D
会变成:
from tensorflow.keras.layers import MaxPooling2D
这篇关于keras 和 tf.keras 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!