Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Microsoft Onnxruntime FloatTensorType Init

From Leeroopedia


Metadata

Field Value
Implementation Name FloatTensorType_Init
Repository Microsoft_Onnxruntime
Source Repository https://github.com/microsoft/onnxruntime
Type Wrapper Doc
Wrapper Tool skl2onnx
Language Python
Domain ML_Inference, Model_Conversion
Last Updated 2026-02-10
Workflow Train_Convert_Predict
Pair 2 of 5

Overview

Wrapper documentation for the skl2onnx.common.data_types.FloatTensorType class, which declares typed tensor specifications for ONNX model input schema definition.

API Signature

skl2onnx.common.data_types.FloatTensorType([None, num_features])

Import

from skl2onnx.common.data_types import FloatTensorType

Code Reference

Reference Location
Usage example docs/python/examples/plot_train_convert_predict.py:L53-55

I/O Contract

Inputs

Parameter Type Required Description
shape list Yes Tensor shape specification. Use None for dynamic dimensions (e.g., batch size). Use integers for fixed dimensions (e.g., feature count).

Outputs

Output Type Description
return value FloatTensorType A typed tensor descriptor used in the initial_type list for ONNX conversion.
initial_type list list[tuple[str, FloatTensorType]] A list of (name, type) tuples passed to convert_sklearn().

Shape Specification

Shape Meaning
[None, 4] Dynamic batch size, 4 features (most common for Iris dataset).
[1, 4] Fixed batch size of 1, 4 features.
[None, N] Dynamic batch size, N features (general pattern).

Usage Example

from skl2onnx.common.data_types import FloatTensorType

# Define input schema for a model with 4 features and dynamic batch size
initial_type = [("float_input", FloatTensorType([None, 4]))]

From the source at docs/python/examples/plot_train_convert_predict.py:L53-55:

from skl2onnx.common.data_types import FloatTensorType

initial_type = [("float_input", FloatTensorType([None, 4]))]
onx = convert_sklearn(clr, initial_types=initial_type)

Fixed Batch Size Variant

From docs/python/examples/plot_train_convert_predict.py:L183 (RandomForest example):

initial_type = [("float_input", FloatTensorType([1, 4]))]

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment