Source code for mlprodict.onnxrt.ops_cpu.op_feature_vectorizer

# -*- encoding: utf-8 -*-
# pylint: disable=E0203,E1101,C0111
"""
Runtime operator.


:githublink:`%|py|7`
"""
import numpy
from ._op import OpRun


[docs]class FeatureVectorizer(OpRun): """ Very similar to :class:`Concat <mlprodict.onnxrt.ops_cpu.op_concat.Concat>`. :githublink:`%|py|14` """
[docs] def __init__(self, onnx_node, desc=None, **options): OpRun.__init__(self, onnx_node, desc=desc, **options) self.axis = 1
[docs] def _preprocess(self, a): if self.axis >= len(a.shape): new_shape = a.shape + (1, ) * (self.axis + 1 - len(a.shape)) return a.reshape(new_shape) return a
[docs] def _run(self, *args): # pylint: disable=W0221 args = [self._preprocess(a) for a in args] res = numpy.concatenate(args, self.axis) return (res, )
[docs] def _infer_shapes(self, *args): # pylint: disable=W0221 return (args[0].concat_columns(self.axis, *(args[1:])), )