ShowModelInputFieldsMap | Vantage BYOM - 3.0 - ONNXPredict Example: Use ShowModelInputFieldsMap to Determine Model Error - Teradata Vantage

Teradata Vantageā„¢ - Bring Your Own Model User Guide

Product
Teradata Vantage
Release Number
3.0
Published
May 2022
Last Update
2022-06-02
Content Type
User Guide
Publication ID
B700-1111-051K
Language
English (United States)

When using ShowModelInputFieldsMap without your own defined ModelInputFieldsMap argument, you are asking the function to show you the default tensor names and mappings of the model.

select TOP 1 * from mldb.ONNXPredict(
    on (select * from iris_short_names)  --- Table contains columns named id, slen, swid, plen, and pwid which differ from the models expected input tensor names.
    on (select * from onnx_models where model_id='tf_iris_softmax_model') DIMENSION
    using
        Accumulate('id')
) as td
;
 
  *** Failure 7825 in UDF/XSP/UDM mldb.ONNXPredict: SQLSTATE [38U01] input tensor columns not found in input table.  Use the ShowModelInputFieldsMap('true') parameter to verify tensor mappings.
 
--> Failure occurs because the ONNX input model is looking for tensor names that do not exist in the input table.  ShowModelInputFieldsMap will show the names it is looking for.
 
Use ShowModelInputFieldsMap to figure out the input tensor error.

select TOP 1 * from mldb.ONNXPredict(
    on (select * from iris_short_names)  --- Table contains columns named id, slen, swid, plen, and pwid which differ from the models expected input tensor names.
    on (select * from onnx_models where model_id='tf_iris_softmax_model') DIMENSION
    using
        Accumulate('id')
        ShowModelInputFieldsMap('true')
) as td
;

*** Query completed. 1 row found. 3 columns returned.
 *** Total elapsed time was 1 second.
        ModelInputFieldsMap   
------------------------------------------------------------------------------------------------------------------
        ModelInputFieldsMap('sepal_length=sepal_length','sepal_width=sepal_width','petal_length=petal_length','petal_width=petal_width'')
  
--> Therefore since we see the default names it is looking for are sepal_length,sepal_width,petal_length,petal_width, we must map the short column names in the input table to the correct names that the model is expecting
  
  
select TOP 1 * from mldb.ONNXPredict(
    on (select * from iris_short_names)  --- Table contains columns named id, slen, swid, plen, and pwid which differ from the models expected input tensor names.
    on (select * from onnx_models where model_id='tf_iris_softmax_model') DIMENSION
    using
        Accumulate('id')
        ModelInputFieldsMap('sepal_length=slen','sepal_width=swid','petal_length=plen','petal_width=pwid')
) as td
;
  
--> now the short names slen, swid, plen, pwid are mapped to the correct names sepal_length,sepal_width,petal_length,petal_width in the model
    
  *** Query completed. 30 rows found. 2 columns returned.
 *** Total elapsed time was 1 second.
  
         id  json_report
-----------  ------------------------------------------------------------------------------------------------
        120  {"probability":[[2.2099151E-8,0.023814192,0.97618586]]}
         85  {"probability":[[1.0646227E-4,0.64747274,0.35242087]]}
        115  {"probability":[[8.84089E-12,1.13627166E-7,0.9999999]]}
         55  {"probability":[[2.3626533E-6,0.9896403,0.010357335]]}
        125  {"probability":[[5.0688627E-9,0.0036252008,0.9963748]]}
         90  {"probability":[[6.0868737E-5,0.9305012,0.06943793]]}
         95  {"probability":[[4.43892E-5,0.98495364,0.015002]]}
        100  {"probability":[[5.467016E-5,0.99671644,0.0032288947]]}
        130  {"probability":[[2.5530914E-8,0.9915139,0.008486167]]}
        135  {"probability":[[1.6936058E-7,0.55152786,0.44847193]]}
        140  {"probability":[[4.6395296E-9,0.004772966,0.995227]]}
         25  {"probability":[[0.99771667,0.0022833364,2.1570362E-11]]}
        110  {"probability":[[5.827173E-11,8.144908E-5,0.9999186]]}
        145  {"probability":[[1.7500341E-11,3.8031712E-6,0.9999962]]}
        150  {"probability":[[2.2181743E-7,0.011317454,0.9886824]]}
         35  {"probability":[[0.999882,1.17950236E-4,2.4415578E-10]]}
         50  {"probability":[[0.99997914,2.0821832E-5,3.7522135E-11]]}
        105  {"probability":[[3.3467944E-11,2.2144119E-5,0.9999778]]}