MCPcopy Create free account
hub / github.com/IceClear/StableSR / _validation_step

Method _validation_step

ldm/models/autoencoder.py:178–203  ·  view source on GitHub ↗
(self, batch, batch_idx, suffix="")

Source from the content-addressed store, hash-verified

176 return log_dict
177
178 def _validation_step(self, batch, batch_idx, suffix=""):
179 x = self.get_input(batch, self.image_key)
180 xrec, qloss, ind = self(x, return_pred_indices=True)
181 aeloss, log_dict_ae = self.loss(qloss, x, xrec, 0,
182 self.global_step,
183 last_layer=self.get_last_layer(),
184 split="val"+suffix,
185 predicted_indices=ind
186 )
187
188 discloss, log_dict_disc = self.loss(qloss, x, xrec, 1,
189 self.global_step,
190 last_layer=self.get_last_layer(),
191 split="val"+suffix,
192 predicted_indices=ind
193 )
194 rec_loss = log_dict_ae[f"val{suffix}/rec_loss"]
195 self.log(f"val{suffix}/rec_loss", rec_loss,
196 prog_bar=True, logger=True, on_step=False, on_epoch=True, sync_dist=True)
197 self.log(f"val{suffix}/aeloss", aeloss,
198 prog_bar=True, logger=True, on_step=False, on_epoch=True, sync_dist=True)
199 if version.parse(pl.__version__) >= version.parse('1.4.0'):
200 del log_dict_ae[f"val{suffix}/rec_loss"]
201 self.log_dict(log_dict_ae)
202 self.log_dict(log_dict_disc)
203 return self.log_dict
204
205 def configure_optimizers(self):
206 lr_d = self.learning_rate

Callers 1

validation_stepMethod · 0.95

Calls 2

get_inputMethod · 0.95
get_last_layerMethod · 0.95

Tested by

no test coverage detected