Output tensors to a Model must be the output of a TensorFlow `Layer`

Output tensors to a Model must be the output of a TensorFlow Layer

使用tensorflow.keras构造网络的时候出现如下错误:

Output tensors to a Model must be the output of a TensorFlow `Layer`

如果是原生keras可能是如下错误:

Output tensors to a Model must be Keras tensors. Found: Tensor

原因,中间网络层构造使用了tf.reduce_mean,导致构建网络失败,应该采用keras的方法构造网络层,keras中的Lambda层刚好满足将tensorflow的操作转换为网络层。

在这里插入图片描述

发布了143 篇原创文章 · 获赞 345 · 访问量 47万+

猜你喜欢

转载自blog.csdn.net/qq_31456593/article/details/89404597
今日推荐