ae46f6e2086e76b566ad23fd6099e84d96a3575f,anago/callbacks.py,F1score,on_epoch_end,#F1score#Any#Any#,58

Before Change


            y_pred = self.model.predict_on_batch(data)
            y_pred = np.argmax(y_pred, -1)

            y_pred = [self.p.inverse_transform(y[:l]) for y, l in zip(y_pred, sequence_lengths)]
            y_true = [self.p.inverse_transform(y[:l]) for y, l in zip(y_true, sequence_lengths)]

After Change


        self.p = preprocessor

    def on_epoch_end(self, epoch, logs={}):
        label_true = []
        label_pred = []
        for i, (data, label) in enumerate(self.valid_batches):
            if i == self.valid_steps:
                break
            y_true = label
            y_true = np.argmax(y_true, -1)
            sequence_lengths = data[-1]  // shape of (batch_size, 1)
            sequence_lengths = np.reshape(sequence_lengths, (-1,))
            y_pred = self.model.predict_on_batch(data)
            y_pred = np.argmax(y_pred, -1)

            y_true = self.p(y_true)
            y_pred = self.p(y_pred)

            label_true.extend(y_true)
            label_pred.extend(y_pred)

        score = f1_score(label_true, label_pred)
        print(" - f1: {:04.2f}".format(score * 100))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: Hironsan/anago
Commit Name: ae46f6e2086e76b566ad23fd6099e84d96a3575f
Time: 2018-03-03
Author: hiroki.nakayama.py@gmail.com
File Name: anago/callbacks.py
Class Name: F1score
Method Name: on_epoch_end


Project Name: Alexander-H-Liu/End-to-end-ASR-Pytorch
Commit Name: 807021e2b3917ef5c0f17d409df5bba12ab5d080
Time: 2019-09-23
Author: alexliu36@gmail.com
File Name: corpus/librispeech.py
Class Name: LibriTextDataset
Method Name: __init__


Project Name: allenai/allennlp
Commit Name: 5f9fb419273f99c949ccdabab22fdc8e9b895c1c
Time: 2019-01-10
Author: andrew.p.moore94@gmail.com
File Name: allennlp/modules/stacked_bidirectional_lstm.py
Class Name: StackedBidirectionalLstm
Method Name: forward