我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用utils.gram_matrix()。
def style_gram_matrices(self): gram_matrices = [] for style_layer in config["style_layers"]: # Get the activations of the given style image at the given style layer style_activation = utils.get_layer_activations(session=self.evaluation_sess, graph=self.evaluation_g, layer_name=style_layer, input_layer_name=self.input_tensor, input=self.style_image) # Construct the gram matrix from the activations and save the matrix to the gram_matrices array gram_matrices.append(utils.gram_matrix(style_activation).astype(np.float32)) return gram_matrices