def get_loss_net(pastiche_net_output, input_tensor=None):
'''
Instantiates a VGG net and applies its layers on top of the pastiche net's
output.
'''
loss_net = vgg16.VGG16(weights='imagenet', include_top=False,
input_tensor=input_tensor)
targets_dict = dict([(layer.name, layer.output) for layer in loss_net.layers])
i = pastiche_net_output
# We need to apply all layers to the output of the style net
outputs_dict = {}
for l in loss_net.layers[1:]: # Ignore the input layer
i = l(i)
outputs_dict[l.name] = i
return loss_net, outputs_dict, targets_dict
评论列表
文章目录