How to use the skl2onnx.common._apply_operation.apply_add function in skl2onnx

To help you get started, we’ve selected a few skl2onnx 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 / sklearn-onnx / skl2onnx / operator_converters / naive_bayes.py View on Github external
num_features = feature_count.shape[1]

        container.add_initializer(threshold_name, proto_type,
                                  [1], [binarize])
        container.add_initializer(
            zero_tensor_name,
            proto_type, [1, num_features],
            np.zeros((1, num_features)).ravel())

        container.add_node(
            'Greater', [input_name, threshold_name],
            condition_name, name=scope.get_unique_operator_name('Greater'),
            op_version=9)
        apply_cast(scope, condition_name, cast_values_name, container,
                   to=proto_type)
        apply_add(scope, [zero_tensor_name, cast_values_name],
                  binarised_input_name, container, broadcast=1)
        input_name = binarised_input_name

    apply_exp(scope, feature_log_prob_name, exp_result_name, container)
    apply_sub(scope, [constant_name, exp_result_name], sub_result_name,
              container, broadcast=1)
    apply_log(scope, sub_result_name, neg_prob_name, container)
    container.add_node('ReduceSum', neg_prob_name,
                       sum_neg_prob_name, axes=[0],
                       name=scope.get_unique_operator_name('ReduceSum'))
    apply_sub(scope, [feature_log_prob_name, neg_prob_name],
              difference_matrix_name, container)
    container.add_node(
        'MatMul', [input_name, difference_matrix_name],
        dot_prod_name, name=scope.get_unique_operator_name('MatMul'))
github onnx / sklearn-onnx / skl2onnx / operator_converters / calibrated_classifier_cv.py View on Github external
sigmoid_predict_result_name = scope.get_unique_variable_name(
        'sigmoid_predict_result')

    container.add_initializer(a_name, onnx_proto.TensorProto.FLOAT,
                              [], [model.calibrators_[k].a_])
    container.add_initializer(b_name, onnx_proto.TensorProto.FLOAT,
                              [], [model.calibrators_[k].b_])
    container.add_initializer(unity_name, onnx_proto.TensorProto.FLOAT,
                              [], [1])

    apply_mul(scope, [a_name, df_col_name], a_df_prod_name, container,
              broadcast=0)
    apply_add(scope, [a_df_prod_name, b_name], exp_parameter_name,
              container, broadcast=0)
    apply_exp(scope, exp_parameter_name, exp_result_name, container)
    apply_add(scope, [unity_name, exp_result_name], denominator_name,
              container, broadcast=0)
    apply_div(scope, [unity_name, denominator_name],
              sigmoid_predict_result_name, container, broadcast=0)
    return sigmoid_predict_result_name
github onnx / sklearn-onnx / skl2onnx / operator_converters / naive_bayes.py View on Github external
desired_shape=[-1, 1, features])
    apply_sub(scope, [reshaped_input_name, theta_name], subtracted_input_name,
              container, broadcast=1)
    apply_pow(scope, [subtracted_input_name, exponent_name], pow_result_name,
              container, broadcast=1)
    apply_div(scope, [pow_result_name, sigma_name], div_result_name,
              container, broadcast=1)
    container.add_node('ReduceSum', div_result_name,
                       reduced_sum_name, axes=[2], keepdims=0,
                       name=scope.get_unique_operator_name('ReduceSum'))
    apply_mul(scope, [reduced_sum_name, prod_operand_name], mul_result_name,
              container, broadcast=1)
    apply_sub(scope, [sigma_sum_log_name, mul_result_name],
              part_log_likelihood_name,
              container, broadcast=1)
    apply_add(scope, [jointi_name, part_log_likelihood_name],
              sum_result_name, container, broadcast=1)
    return sum_result_name
github onnx / sklearn-onnx / skl2onnx / operator_converters / calibrated_classifier_cv.py View on Github external
container.add_initializer(n_classes_name, onnx_proto.TensorProto.FLOAT,
                              [], [n_classes])

    apply_cast(scope, reduced_prob_name, cast_prob_name, container,
               to=onnx_proto.TensorProto.BOOL)
    container.add_node('Not', cast_prob_name,
                       bool_not_cast_prob_name,
                       name=scope.get_unique_operator_name('Not'))
    apply_cast(scope, bool_not_cast_prob_name, mask_name, container,
               to=onnx_proto.TensorProto.FLOAT)
    apply_add(scope, [concatenated_prob_name, mask_name],
              masked_concatenated_prob_name, container, broadcast=1)
    apply_mul(scope, [mask_name, n_classes_name], reduced_prob_mask_name,
              container, broadcast=1)
    apply_add(scope, [reduced_prob_name, reduced_prob_mask_name],
              masked_reduced_prob_name, container, broadcast=0)
    return masked_concatenated_prob_name, masked_reduced_prob_name
github onnx / sklearn-onnx / skl2onnx / operator_converters / sgd_classifier.py View on Github external
container.add_initializer(intercept_name, onnx_proto.TensorProto.FLOAT,
                              model.intercept_.shape, model.intercept_)

    input_name = operator.inputs[0].full_name
    if type(operator.inputs[0].type) == Int64TensorType:
        cast_input_name = scope.get_unique_variable_name('cast_input')

        apply_cast(scope, operator.input_full_names, cast_input_name,
                   container, to=onnx_proto.TensorProto.FLOAT)
        input_name = cast_input_name

    container.add_node(
        'MatMul', [input_name, coef_name],
        matmul_result_name,
        name=scope.get_unique_operator_name('MatMul'))
    apply_add(scope, [matmul_result_name, intercept_name],
              score_name, container, broadcast=0)
    return score_name
github onnx / sklearn-onnx / skl2onnx / operator_converters / calibrated_classifier_cv.py View on Github external
reduced_prob_mask_name = scope.get_unique_variable_name(
        'reduced_prob_mask')
    masked_reduced_prob_name = scope.get_unique_variable_name(
        'masked_reduced_prob')

    container.add_initializer(n_classes_name, onnx_proto.TensorProto.FLOAT,
                              [], [n_classes])

    apply_cast(scope, reduced_prob_name, cast_prob_name, container,
               to=onnx_proto.TensorProto.BOOL)
    container.add_node('Not', cast_prob_name,
                       bool_not_cast_prob_name,
                       name=scope.get_unique_operator_name('Not'))
    apply_cast(scope, bool_not_cast_prob_name, mask_name, container,
               to=onnx_proto.TensorProto.FLOAT)
    apply_add(scope, [concatenated_prob_name, mask_name],
              masked_concatenated_prob_name, container, broadcast=1)
    apply_mul(scope, [mask_name, n_classes_name], reduced_prob_mask_name,
              container, broadcast=1)
    apply_add(scope, [reduced_prob_name, reduced_prob_mask_name],
              masked_reduced_prob_name, container, broadcast=0)
    return masked_concatenated_prob_name, masked_reduced_prob_name
github onnx / sklearn-onnx / skl2onnx / operator_converters / sgd_classifier.py View on Github external
proba_updated_name = scope.get_unique_variable_name('proba_updated')
    mask_name = scope.get_unique_variable_name('mask')
    reduced_proba_updated_name = scope.get_unique_variable_name(
        'reduced_proba_updated')

    container.add_initializer(num_classes_name, onnx_proto.TensorProto.FLOAT,
                              [], [num_classes])

    apply_cast(scope, reduced_proba, bool_reduced_proba_name, container,
               to=onnx_proto.TensorProto.BOOL)
    container.add_node('Not', bool_reduced_proba_name,
                       bool_not_reduced_proba_name,
                       name=scope.get_unique_operator_name('Not'))
    apply_cast(scope, bool_not_reduced_proba_name, not_reduced_proba_name,
               container, to=onnx_proto.TensorProto.FLOAT)
    apply_add(scope, [proba, not_reduced_proba_name],
              proba_updated_name, container, broadcast=1)
    apply_mul(scope, [not_reduced_proba_name, num_classes_name],
              mask_name, container, broadcast=1)
    apply_add(scope, [reduced_proba, mask_name],
              reduced_proba_updated_name, container, broadcast=0)
    return proba_updated_name, reduced_proba_updated_name