aboutsummaryrefslogtreecommitdiff
path: root/losses.py
diff options
context:
space:
mode:
authorLogan Bauman <logan_bauman@brown.edu>2022-05-07 08:12:20 -0400
committerLogan Bauman <logan_bauman@brown.edu>2022-05-07 08:12:20 -0400
commit10f2ece4ab4d8df526c5ff77958b25fe6f32344d (patch)
tree8ce1826fa3b64549dc04e0c3cfd2053aa9eb6dc6 /losses.py
parent718f2a66accddc9e1ff619c478e3cdce1b39333a (diff)
hi
Diffstat (limited to 'losses.py')
-rw-r--r--losses.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/losses.py b/losses.py
index 5564ca33..4c7b5750 100644
--- a/losses.py
+++ b/losses.py
@@ -34,7 +34,7 @@ class YourModel(tf.keras.Model):
#print(self.content_image.shape, self.style_image.shape)
- self.optimizer = tf.keras.optimizers.Adam()
+ self.optimizer = tf.keras.optimizers.Adam(1e-2)
self.vgg16 = [
# Block 1
@@ -112,6 +112,8 @@ class YourModel(tf.keras.Model):
content_l = self.content_loss(self.photo_layers, input_layers)
style_l = self.style_loss(self.art_layers, input_layers)
# Equation 7
+ print('style_loss', style_l)
+ print('content_loss', content_l)
return (self.alpha * content_l) + (self.beta * style_l)
def content_loss(self, photo_layers, input_layers):
@@ -164,7 +166,7 @@ class YourModel(tf.keras.Model):
for i in range(len(art_layers)):
art_layer = art_layers[i]
input_layer = input_layers[i]
- L_style = tf.math.add(L_style, self.layer_loss(art_layer, input_layer))
+ L_style = tf.math.add(L_style, self.layer_loss(art_layer, input_layer)*(1/5))
#print('style loss', L_style)
return L_style