操作:原本想在網(wǎng)絡(luò)中對輸入圖像tensor進(jìn)行裁剪,直接用了x = x[:, 0:h2, w1:w3]
.
報錯:Keras AttributeError: 'NoneType' object has no attribute '_inbound_nodes'
原因:Keras搭建的網(wǎng)絡(luò)中要用層來表示的等限,不能直接用Tensor或是Numpy。
解決方案:利用Lambda封裝成一個Layer所宰。
示例如下:
slice_input = Lambda(lambda x: x[:, 0:h2, w1:w3])(img_input)
PS:
另外一種類似報錯:ValueError: Output tensors to a Model must be the output of a TensorFlow 'Layer'