Пример #1
0
 def get_style_loss(self, ws, Gs, As):
     style_loss = K.variable(0.)
     for w, G, A in zip(ws, Gs, As):
         M_l = K.int_shape(G)[1]
         N_l = K.int_shape(G)[0]
         G_gram = self.get_gram_matrix(G)
         A_gram = self.get_gram_matrix(A)
         style_loss += w*0.25*K.sum(K.square(G_gram - A_gram))/ (N_l**2 * M_l**2)
     return style_loss
Пример #2
0
 def get_content_loss(self, F, P):
     '''
     Calculuates the content loss using mean squared error
     '''
     content_loss = 0.5*K.sum(K.square(F - P))
     return content_loss