Model was constructed with shape for input Tensor(). but it was called on an input with incompatible

在构建深度模型进行训练的过程中,报了一个如下一个警告:

warning: tensorflow:Model was constructed with shape for input Tensor(None,9,7). but it was called on an input with incompatible shape(None,7)

虽然模型接着往下跑了,但是还是想消除下告警。

 

这个告警的意思是:模型期望的输入形状是(None,9,7) ,但是输入的形状为(None,7)。

我的代码中输入形状是(9,7),

原因:这里的None是模型为batch预留的,比如batch size为32,实际在训练过程中,None就会变为32。因此需要把输入形状改为(batch_size,9,7)。

增加如下一句:

input = np.expand_dims(input,axis=0)

然后就OK了

 


版权声明:本文为qq_22498427原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。