Python `tf.keras.Model.compile`在TF2.0中做什么?

Python `tf.keras.Model.compile`在TF2.0中做什么?,python,tensorflow,keras,tensorflow2.0,Python,Tensorflow,Keras,Tensorflow2.0,在TF2.0中,仍然需要在创建keras模型后调用model.compile,如中所示 但是使用渴望模式时,不需要创建图形,那么Tensorflow 2.0中的tf.keras.Model.compile有什么用呢?Model.compile与图形模式无关,它定义了损失、优化器和度量,与tf 1.x中的keras和tf.keras一样。该图只是一个内部细节,与model.compile没有真正的关联

在TF2.0中,仍然需要在创建keras模型后调用
model.compile
,如中所示


但是使用渴望模式时,不需要创建图形,那么Tensorflow 2.0中的
tf.keras.Model.compile
有什么用呢?

Model.compile
与图形模式无关,它定义了损失、优化器和度量,与tf 1.x中的
keras
tf.keras
一样。该图只是一个内部细节,与
model.compile
没有真正的关联