(self, valid_iter)
return stats
Validate model.
            valid_iter: validate data iterator
        Returns:
            :obj:`nmt.Statistics`: validation loss statistics
Validate model.
            valid_iter: validate data iterator
        Returns:
            :obj:`nmt.Statistics`: validation loss statistics
Validate model . valid_iter : validate data iterator Returns : : obj : nmt . Statistics : validation loss statistics
def validate(self, valid_iter):
        """ Validate model.
            valid_iter: validate data iterator
        Returns:
            :obj:`nmt.Statistics`: validation loss statistics
        """
        # Set model in validating mode.
        self.model.eval()

        stats = onmt.utils.Statistics()


        for batch in valid_iter:
            src = inputters.make_features(batch, 'src', self.data_type)
            if self.data_type == 'text':
                _, src_lengths = batch.src
            else:
                src_lengths = None

            tgt = inputters.make_features(batch, 'tgt')

            # F-prop through the model.
            src_sents = batch.src_sents
            outputs, attns, _ = self.model(src, tgt, src_sents,src_lengths)

            # Compute loss.
            batch_stats = self.valid_loss.monolithic_compute_loss(
                batch, outputs, attns)

            # Update statistics.
            stats.update(batch_stats)

        # Set model back to training mode.
        self.model.train()

        return stats
def validate ( self , valid_iter ) : # Set model in validating mode. self . model . eval ( ) stats = onmt . utils . Statistics ( ) for batch in valid_iter : src = inputters . make_features ( batch , 'src' , self . data_type ) if self . data_type == 'text' : _ , src_lengths = batch . src else : src_lengths = None tgt = inputters . make_features ( batch , 'tgt' ) # F-prop through the model. src_sents = batch . src_sents outputs , attns , _ = self . model ( src , tgt , src_sents , src_lengths ) # Compute loss. batch_stats = self . valid_loss . monolithic_compute_loss ( batch , outputs , attns ) # Update statistics. stats . update ( batch_stats ) # Set model back to training mode. self . model . train ( ) return stats