(self)
Compiles keras model with losses
Compiles keras model with losses
Compiles keras model with losses
def _compile_model(self):
        """
        Compiles keras model with losses
        """
        losses = {}
        loss_weights = {}

        umap_loss_fn = umap_loss(
            self.batch_size,
            self.negative_sample_rate,
            self._a,
            self._b,
            self.edge_weight,
            self.parametric_embedding,
        )
        losses["umap"] = umap_loss_fn
        loss_weights["umap"] = 1.0

        if self.global_correlation_loss_weight > 0:
            losses["global_correlation"] = distance_loss_corr
            loss_weights["global_correlation"] = self.global_correlation_loss_weight
            if self.run_eagerly == False:
                # this is needed to avoid a 'NaN' error bug in tensorflow_probability (v0.12.2)
                warn("Setting tensorflow to run eagerly for global_correlation_loss.")
                self.run_eagerly = True

        if self.parametric_reconstruction:
            losses["reconstruction"] = self.parametric_reconstruction_loss_fcn
            loss_weights["reconstruction"] = self.parametric_reconstruction_loss_weight

        self.parametric_model.compile(
            optimizer=self.optimizer,
            loss=losses,
            loss_weights=loss_weights,
            run_eagerly=self.run_eagerly,
        )
def _compile_model ( self ) : losses = { } loss_weights = { } umap_loss_fn = umap_loss ( self . batch_size , self . negative_sample_rate , self . _a , self . _b , self . edge_weight , self . parametric_embedding , ) losses [ "umap" ] = umap_loss_fn loss_weights [ "umap" ] = 1.0 if self . global_correlation_loss_weight > 0 : losses [ "global_correlation" ] = distance_loss_corr loss_weights [ "global_correlation" ] = self . global_correlation_loss_weight if self . run_eagerly == False : # this is needed to avoid a 'NaN' error bug in tensorflow_probability (v0.12.2) warn ( "Setting tensorflow to run eagerly for global_correlation_loss." ) self . run_eagerly = True if self . parametric_reconstruction : losses [ "reconstruction" ] = self . parametric_reconstruction_loss_fcn loss_weights [ "reconstruction" ] = self . parametric_reconstruction_loss_weight self . parametric_model . compile ( optimizer = self . optimizer , loss = losses , loss_weights = loss_weights , run_eagerly = self . run_eagerly , )