def __call__(self, y_true, y_pred): # initial shape is (batch_size, squence_length, n_classes) conds_list = self.cond(y_true, y_pred) #+ (y_true_wo_index_mask, ) conds_xd = K.cast(K.stack(conds_list, axis=-1), 'bool') res = K.sum(K.cast(K.all(conds_xd, axis=-1), 'int32')) updates = [keras.backend.update_add(self.count, res)] self.add_update(updates) return self.count
def seq_accuracy(y_true, y_pred): return K.cast(K.all(K.equal(y_true, K.round(y_pred)), axis=-2), 'float32')