How to use the onnxmltools.convert.common.utils.check_input_and_output_types function in onnxmltools

To help you get started, we’ve selected a few onnxmltools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onnx / onnxmltools / onnxmltools / convert / sklearn / shape_calculators / Scaler.py View on Github external
def calculate_sklearn_scaler_output_shapes(operator):
    '''
    Allowed input/output patterns are
        1. [N, C_1], ..., [N, C_n] ---> [N, C_1 + ... + C_n]

    Similar to imputer, this operator can take multiple input feature tensors and concatenate them along C-axis.
    '''
    check_input_and_output_numbers(operator, input_count_range=[1, None], output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType, Int64TensorType],
                                 good_output_types=[FloatTensorType])
    # Inputs: multiple float- and integer-tensors
    # Output: one float tensor
    for variable in operator.inputs:
        if len(variable.type.shape) != 2:
            raise RuntimeError('Only 2-D tensor(s) can be input(s)')
        if len(set(variable.type.shape[0] for variable in operator.inputs)) > 1:
            raise RuntimeError('Batch size must be identical across inputs')

    N = operator.inputs[0].type.shape[0]
    C = 0
    for variable in operator.inputs:
        if isinstance(variable.type.shape[1], numbers.Integral):
            C += variable.type.shape[1]
        else:
            C = 'None'
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / stop_words_remover.py View on Github external
def calculate_sparkml_stop_words_remover_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator,
                                 good_input_types=[StringTensorType])
    input_shape = copy.deepcopy(operator.inputs[0].type.shape)
    operator.outputs[0].type = StringTensorType(input_shape)
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / bucketed_random_projection_lsh.py View on Github external
def calculate_min_hash_lsh_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])

    N = operator.inputs[0].type.shape[0]
    C = 1
    operator.outputs[0].type = FloatTensorType([N, C])
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / pca.py View on Github external
def calculate_sparkml_pca_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])
    N = operator.inputs[0].type.shape[0]
    operator.outputs[0].type = FloatTensorType([N, operator.raw_operator.getOrDefault('k')])
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / chi_sq_selector.py View on Github external
def calculate_chi_sq_selector_shapes(operator):
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator,
                                 good_input_types=[FloatTensorType, Int64TensorType, StringTensorType])
    operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
    operator.outputs[0].type.shape[1] = len(operator.raw_operator.selectedFeatures)
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / bucketizer.py View on Github external
def calculate_bucketizer_output_shapes(operator):
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator,
                                 good_input_types=[FloatTensorType],
                                 good_output_types=[FloatTensorType])
    input_type = copy.deepcopy(operator.inputs[0].type)
    for output in operator.outputs:
        output.type = input_type
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / imputer.py View on Github external
def calculate_imputer_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=[1, len(operator.outputs)])
    check_input_and_output_types(operator,
                                 good_input_types=[FloatTensorType, Int64TensorType],
                                 good_output_types=[FloatTensorType, Int64TensorType])
    input_type = copy.deepcopy(operator.inputs[0].type)
    for output in operator.outputs:
        output.type = input_type
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / naive_bayes.py View on Github external
def calculate_sparkml_naive_bayes_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=2)
    check_input_and_output_types(operator,
                                 good_input_types=[FloatTensorType],
                                 good_output_types=[FloatTensorType,FloatTensorType])
    N = operator.inputs[0].type.shape[0]
    C = operator.raw_operator.numClasses
    operator.outputs[0].type = FloatTensorType([N, 1])
    operator.outputs[1].type = FloatTensorType([N, C])
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / dct.py View on Github external
def calculate_sparkml_dct_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])
    operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
github onnx / onnxmltools / onnxmltools / convert / sparkml / operator_converters / vector_slicer.py View on Github external
def calculate_vector_slicer_shapes(operator):
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator,
                                 good_input_types=[FloatTensorType, Int64TensorType, StringTensorType])
    operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
    operator.outputs[0].type.shape[1] = len(operator.raw_operator.getIndices())