Keras与Tensorflow混用 报错Keras AttributeError: 'Tensor' object has no attribute '_keras_history'

第一种策略:将tensorflow tensor转keras tensor

1.索引操作转换

#转换前
x = self.x[:, :, :, :]
#转换后
x=Lambda(lambda x: x[:, :, :, :])(self.x)

2.tf操作以及K操作转换

x=Lambda(lambda x: K.round(x))(x)

3.带有非tensor参数的函数转换

offset = Lambda(self.conv,arguments={'co': 2 * N, 'mode': 'offset'})(x)

猜你喜欢

转载自blog.csdn.net/u011489887/article/details/85170426
今日推荐