示例#1
0
    def do(self, callback_name, *args):
        """calculate PER and monitor it's mean, min and max """
        per = []
        for batch in self.data_stream.get_epoch_iterator(as_dict=True):
            inputs=batch[conf.input_theano]
            input_masks = batch[conf.input_mask_theano]
            targets = batch[conf.target_theano]
            target_masks = batch[conf.target_mask_theano]

            outputs = self.getOutput(inputs, input_masks)
            decoded = self.decodeSequences(outputs, input_masks)
            targets = self.maskTargets(targets,target_masks)

            if conf.mapTo39Phonemes_Decoding:
                scoreMap = getPhonemeMapForScoring()
                decoded = self.mapForScoring(decoded, scoreMap)
                targets = self.mapForScoring(targets, scoreMap)

            for t,d in zip(targets,decoded):
                per.append(np.min([self.per(t,d),1]))
        per=np.asarray(per)

        accuracies_dict={'meanPER':np.mean(per), # mean accuracy over epoch
                         'minPER':np.min(per),
                         'maxPER':np.max(per),
                         }
        self.add_records(self.main_loop.log, accuracies_dict.items())
示例#2
0
    def do(self, callback_name, *args):
        """calculate PER and monitor it's mean, min and max """
        per = []
        for batch in self.data_stream.get_epoch_iterator(as_dict=True):
            inputs = batch[conf.input_theano]
            input_masks = batch[conf.input_mask_theano]
            targets = batch[conf.target_theano]
            target_masks = batch[conf.target_mask_theano]

            outputs = self.getOutput(inputs, input_masks)
            decoded = self.decodeSequences(outputs, input_masks)
            targets = self.maskTargets(targets, target_masks)

            if conf.mapTo39Phonemes_Decoding:
                scoreMap = getPhonemeMapForScoring()
                decoded = self.mapForScoring(decoded, scoreMap)
                targets = self.mapForScoring(targets, scoreMap)

            for t, d in zip(targets, decoded):
                per.append(np.min([self.per(t, d), 1]))
        per = np.asarray(per)

        accuracies_dict = {
            'meanPER': np.mean(per),  # mean accuracy over epoch
            'minPER': np.min(per),
            'maxPER': np.max(per),
        }
        self.add_records(self.main_loop.log, accuracies_dict.items())
示例#3
0
    def do(self, callback_name, *args):
        """Write the values of monitored variables to the log."""
        per = []
        for batch in self.data_stream.get_epoch_iterator(as_dict=True):
            inputs=batch[conf.input_theano]
            masks = batch[conf.input_mask_theano]
            targets = batch[conf.target_theano]
            outputs = self.getOutput(inputs, masks)
            decoded = self.decodeSequences(outputs)

            if conf.mapTo39Phonemes_Decoding:
                scoreMap = getPhonemeMapForScoring()
                decoded = self.mapForScoring(decoded, scoreMap)
                targets = self.mapForScoring(targets, scoreMap)

            per.append(np.min([self.per(targets,decoded,masks),1]))
        per=np.asarray(per)

        accuracies_dict={'meanPER':np.mean(per), # mean accuracy over epoch
                         'varPER':np.var(per),
                         'minPER':np.min(per),
                         'maxPER':np.max(per),
                         #'decoded':d,
                         #'taget':t,
                         #'orig outputs':outputs,
                         }
        self.add_records(self.main_loop.log, accuracies_dict.items())
示例#4
0
    def do(self, callback_name, *args):
        """Write the values of monitored variables to the log."""
        per = []
        for batch in self.data_stream.get_epoch_iterator(as_dict=True):
            inputs = batch[conf.input_theano]
            masks = batch[conf.input_mask_theano]
            targets = batch[conf.target_theano]
            outputs = self.getOutput(inputs, masks)
            decoded = self.decodeSequences(outputs)

            if conf.mapTo39Phonemes_Decoding:
                scoreMap = getPhonemeMapForScoring()
                decoded = self.mapForScoring(decoded, scoreMap)
                targets = self.mapForScoring(targets, scoreMap)

            per.append(np.min([self.per(targets, decoded, masks), 1]))
        per = np.asarray(per)

        accuracies_dict = {
            'meanPER': np.mean(per),  # mean accuracy over epoch
            'varPER': np.var(per),
            'minPER': np.min(per),
            'maxPER': np.max(per),
            #'decoded':d,
            #'taget':t,
            #'orig outputs':outputs,
        }
        self.add_records(self.main_loop.log, accuracies_dict.items())