I'm trying to implement the VGG perceptual loss for a model training for video inputs. I implemented the perceptual loss like the recommendation in the question AttributeError: 'Tensor' object has no attribute '_keras_history':
My mainModel looks like the following graph: Graph of mainModel
The input size is (bathsize, frame_num, row, col, channel)
. And I want to get the perceptual loss for the middle frame, that is, frame_num/2
.
So, I implemented the following lossModel:
lossModel = VGG19(weights='imagenet')
lossModel = Model(inputs=lossModel.input,outputs=lossModel.get_layer('block3_conv4').output)
lossOut = lossModel(mainModel.output[:,frame_num/2])
fullModel = Model(mainModel.input,lossOut)
But I faced an error message in the line fullModel = Model(mainModel.input, lossOut)
:
attributeError: 'Tensor' object has no attribute '_keras_history'
BTW, I'm using keras version is '2.0.9'.
Could anyone help me with this?
THANKS a lot!!