今天发现tf.keras.Model.outputs的隐藏问题(feature),我居然之前都没有发现233

描述

其实就是我这次的模型输出的是List[Tuple]的方式,然后我以为keras的模型输出还是List的形式,算loss的时候就一直出错.

train_model.outputs
[<tf.Tensor 'MConv_Stage1_L1_5_bn/Identity:0' shape=(None, 80, 120, 38) dtype=float32>,
<tf.Tensor 'MConv_Stage1_L2_5_bn/Identity:0' shape=(None, 80, 120, 19) dtype=float32>,
<tf.Tensor 'MConv_Stage2_L1_5_bn/Identity:0' shape=(None, 80, 120, 38) dtype=float32>,
<tf.Tensor 'MConv_Stage2_L2_5_bn/Identity:0' shape=(None, 80, 120, 19) dtype=float32>,
<tf.Tensor 'MConv_Stage3_L1_5_bn/Identity:0' shape=(None, 80, 120, 38) dtype=float32>,
<tf.Tensor 'MConv_Stage3_L2_5_bn/Identity:0' shape=(None, 80, 120, 19) dtype=float32>,
<tf.Tensor 'MConv_Stage4_L1_5_bn/Identity:0' shape=(None, 80, 120, 38) dtype=float32>,
<tf.Tensor 'MConv_Stage4_L2_5_bn/Identity:0' shape=(None, 80, 120, 19) dtype=float32>,
<tf.Tensor 'MConv_Stage5_L1_5_bn/Identity:0' shape=(None, 80, 120, 38) dtype=float32>,
<tf.Tensor 'MConv_Stage5_L2_5_bn/Identity:0' shape=(None, 80, 120, 19) dtype=float32>]

然后我发现实际上模型的输出就是按原本的形式:

train_model.output_shape
[((None, 80, 120, 38), (None, 80, 120, 19)),
((None, 80, 120, 38), (None, 80, 120, 19)),
((None, 80, 120, 38), (None, 80, 120, 19)),
((None, 80, 120, 38), (None, 80, 120, 19)),
((None, 80, 120, 38), (None, 80, 120, 19))]

结论就是tf.keras比我想的完善多了233