Skip to content
Snippets Groups Projects
Commit e1951bb4 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 8a4bd4b3
No related branches found
No related tags found
No related merge requests found
...@@ -611,12 +611,13 @@ class SRCNN: ...@@ -611,12 +611,13 @@ class SRCNN:
self.train_accuracy = tf.keras.metrics.SparseCategoricalAccuracy(name='train_accuracy') self.train_accuracy = tf.keras.metrics.SparseCategoricalAccuracy(name='train_accuracy')
self.test_accuracy = tf.keras.metrics.SparseCategoricalAccuracy(name='test_accuracy') self.test_accuracy = tf.keras.metrics.SparseCategoricalAccuracy(name='test_accuracy')
@tf.function(input_signature=[tf.TensorSpec(None, tf.float32), tf.TensorSpec(None, tf.float32)]) # @tf.function(input_signature=[tf.TensorSpec(None, tf.float32), tf.TensorSpec(None, tf.float32)])
@tf.function
def train_step(self, inputs, labels): def train_step(self, inputs, labels):
labels = tf.squeeze(labels, axis=[3]) labels = tf.squeeze(labels, axis=[3])
with tf.GradientTape() as tape: with tf.GradientTape() as tape:
# pred = self.model([inputs], training=True) # pred = self.model(inputs, training=True)
pred = self.model({'2km': inputs[0], 'hkm': inputs[1]}, training=True) pred = self.model({'input_1': inputs[0], 'input_2': inputs[1]}, training=True)
loss = self.loss(labels, pred) loss = self.loss(labels, pred)
total_loss = loss total_loss = loss
if len(self.model.losses) > 0: if len(self.model.losses) > 0:
...@@ -632,11 +633,12 @@ class SRCNN: ...@@ -632,11 +633,12 @@ class SRCNN:
return loss return loss
@tf.function(input_signature=[tf.TensorSpec(None, tf.float32), tf.TensorSpec(None, tf.float32)]) # @tf.function(input_signature=[tf.TensorSpec(None, tf.float32), tf.TensorSpec(None, tf.float32)])
@tf.function
def test_step(self, inputs, labels): def test_step(self, inputs, labels):
labels = tf.squeeze(labels, axis=[3]) labels = tf.squeeze(labels, axis=[3])
# pred = self.model([inputs], training=False) # pred = self.model(inputs, training=False)
pred = self.model({'2km': inputs[0], 'hkm': inputs[1]}, training=False) pred = self.model({'input_1': inputs[0], 'input_2': inputs[1]}, training=False)
t_loss = self.loss(labels, pred) t_loss = self.loss(labels, pred)
self.test_loss(t_loss) self.test_loss(t_loss)
...@@ -645,8 +647,8 @@ class SRCNN: ...@@ -645,8 +647,8 @@ class SRCNN:
# @tf.function(input_signature=[tf.TensorSpec(None, tf.float32), tf.TensorSpec(None, tf.float32)]) # @tf.function(input_signature=[tf.TensorSpec(None, tf.float32), tf.TensorSpec(None, tf.float32)])
# decorator commented out because pred.numpy(): pred not evaluated yet. # decorator commented out because pred.numpy(): pred not evaluated yet.
def predict(self, inputs, labels): def predict(self, inputs, labels):
# pred = self.model([inputs], training=False) # pred = self.model(inputs, training=False)
pred = self.model({'2km': inputs[0], 'hkm': inputs[1]}, training=False) pred = self.model({'input_1': inputs[0], 'input_2': inputs[1]}, training=False)
# t_loss = self.loss(tf.squeeze(labels, axis=[3]), pred) # t_loss = self.loss(tf.squeeze(labels, axis=[3]), pred)
t_loss = self.loss(labels, pred) t_loss = self.loss(labels, pred)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment