问题:AttributeError: ‘NoneType‘ object has no attribute ‘_inbound_nodes‘
背景:tf1.14 keras2.2.4 构建网络模型,对输入数据进行shape调整时
错误代码:
b_row = Lambda(tf.expand_dims, argument={'axis': 1})(b_input[;, :4:-1, :]) #b_input[16,9,3]
解决方案:需要把切片索引和扩维拆开写成两个lambda层的形式,直接将数据切片再送入Lambda层会报错
正确代码:
b_row = Lambda(lambda x: x[;, :4:-1, :])(b_input) # 切片索引
b_row = Lambda(tf.expand_dims, argument={'axis': 1})(b_row ) #扩维