Skip to content

Instantly share code, notes, and snippets.

@Crazz-Zaac
Last active February 26, 2021 03:52
Show Gist options
  • Save Crazz-Zaac/961f9f6b4950133a29966d09a4d2cd80 to your computer and use it in GitHub Desktop.
Save Crazz-Zaac/961f9f6b4950133a29966d09a4d2cd80 to your computer and use it in GitHub Desktop.
###content cost
# Assign the content image to be the input of the VGG model.
sess.run(model['input'].assign(content_image))
# Select the output tensor of layer conv4_2
out = model['conv4_2']
# Set a_C to be the hidden layer activation from the layer we have selected
a_C = sess.run(out)
# Set a_G to be the hidden layer activation from same layer. Here, a_G references model['conv4_2']
# and isn't evaluated yet. Later in the code, we'll assign the image G as the model input, so that
# when we run the session, this will be the activations drawn from the appropriate layer, with G as input.
a_G = out
# Compute the content cost
J_content = compute_content_cost(a_C, a_G)
###style cost
# Assign the input of the model to be the "style" image
sess.run(model['input'].assign(style_image))
# Compute the style cost
J_style = compute_style_cost(model, STYLE_LAYERS)
###total cost
### START CODE HERE ### (1 line)
J = total_cost(J_content, J_style, alpha = 10, beta = 40)
### END CODE HERE ###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment