{"record":{"id":"dad63f2e9c0df9ad","repo":"dotnet/machinelearning","slug":"tensorflow-type-not-supported","errorCode":null,"errorMessage":"TensorFlow type not supported.","messagePattern":"TensorFlow type not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.ML.TensorFlow/TensorflowUtils.cs","lineNumber":153,"sourceCode":"\n        /// <summary>\n        /// Load TensorFlow model into memory.\n        /// </summary>\n        /// <param name=\"env\">The environment to use.</param>\n        /// <param name=\"modelPath\">The model to load.</param>\n        /// <param name=\"treatOutputAsBatched\">If the first dimension of the output is unknown, should it be treated as batched or not.</param>\n        /// <returns></returns>\n        internal static TensorFlowModel LoadTensorFlowModel(IHostEnvironment env, string modelPath, bool treatOutputAsBatched = true)\n        {\n            var session = GetSession(env, modelPath);\n            return new TensorFlowModel(env, session, modelPath, treatOutputAsBatched: treatOutputAsBatched);\n        }\n\n        internal static PrimitiveDataViewType Tf2MlNetType(TF_DataType type)\n        {\n            var mlNetType = Tf2MlNetTypeOrNull(type);\n            if (mlNetType == null)\n                throw new NotSupportedException(\"TensorFlow type not supported.\");\n            return mlNetType;\n        }\n\n        internal static PrimitiveDataViewType Tf2MlNetTypeOrNull(TF_DataType type)\n        {\n            switch (type)\n            {\n                case TF_DataType.TF_FLOAT:\n                    return NumberDataViewType.Single;\n                case TF_DataType.DtFloatRef:\n                    return NumberDataViewType.Single;\n                case TF_DataType.TF_DOUBLE:\n                    return NumberDataViewType.Double;\n                case TF_DataType.TF_UINT8:\n                    return NumberDataViewType.Byte;\n                case TF_DataType.TF_UINT16:\n                    return NumberDataViewType.UInt16;\n                case TF_DataType.TF_UINT32:","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.ML.TensorFlow/TensorflowUtils.cs#L135-L171","documentation":"Tf2MlNetType maps a TF_DataType to an ML.NET PrimitiveDataViewType. If Tf2MlNetTypeOrNull returns null (the TF type has no ML.NET equivalent), it throws NotSupportedException(\"TensorFlow type not supported.\").","triggerScenarios":"Loading a TensorFlow model (TensorFlowTransformer/TensorFlowEstimator) whose input or output tensors use a dtype without an ML.NET mapping — e.g. TF_COMPLEX64, TF_UINT32, TF_QINT8, TF_RESOURCE, or other exotic quantized/resource types.","commonSituations":"Using SavedModels that export quantized (QINT/QUINT), complex, string-resource, or variant outputs; TF 2.x models exposing control-flow/resource tensors; models saved with unusual dtypes for embeddings or hashes.","solutions":["Re-export the model with only supported dtypes (float32, double, int32, int64, string, bool) on inputs/outputs.","Wrap the unsupported tensor with TF cast ops to a supported type before the model's output.","Check Tf2MlNetTypeOrNull over all model signatures before training/loading to detect unsupported dtypes early.","Catch NotSupportedException and fall back to a different model or featurization path."],"exampleFix":"// before\nvar type = Tf2MlNetType(TF_DataType.TF_QINT8); // throws\n// after\nvar type = Tf2MlNetTypeOrNull(dtype) ?? Tf2MlNetType(TF_DataType.TF_FLOAT); // after casting model outputs to float","handlingStrategy":"validation","validationCode":"foreach (var dtype in modelInputAndOutputDtypes)\n    if (Tf2MlNetTypeOrNull(dtype) == null)\n        throw new InvalidOperationException($\"Model uses unsupported TF dtype {dtype}\");","typeGuard":null,"tryCatchPattern":"try { type = Tf2MlNetType(dtype); }\ncatch (NotSupportedException) { useFallbackModelOrCastToFloat(); }","preventionTips":["Inspect SavedModel signatures for quantized/complex/resource dtypes before loading","Re-export models casting outputs to float32/int32/int64/string","Prefer models trained/exported specifically for ML.NET interop"],"tags":["tensorflow","dtype","mlnet-type","not-supported"],"backgroundTag":"unsupported-dtype","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}