TensorFlowScorer Class

Transforms the data using the TensorFlow model.

Inheritance
nimbusml.internal.core.preprocessing._tensorflowscorer.TensorFlowScorer
TensorFlowScorer
nimbusml.base_transform.BaseTransform
TensorFlowScorer
sklearn.base.TransformerMixin
TensorFlowScorer

Constructor

TensorFlowScorer(model_location, input_columns=None, output_columns=None, batch_size=64, add_batch_dimension_inputs=False, columns=None, **params)

Parameters

columns

see Columns.

model_location

TensorFlow model used by the transform. Please see https://www.tensorflow.org/mobile/prepare_models for more details.

input_columns

The names of the model inputs.

output_columns

The name of the outputs.

batch_size

Number of samples to use for mini-batch training.

add_batch_dimension_inputs

Add a batch dimension to the input e.g. input = [224, 224, 3] => [-1, 224, 224, 3].

params

Additional arguments sent to compute engine.

Examples


   ###############################################################################
   # TensorFlowScorer
   import os
   from nimbusml import FileDataStream
   from nimbusml.preprocessing import TensorFlowScorer
   import pandas as pd
   import numpy as np

   data = pd.DataFrame(np.ones(9) * 1.1)
   data.to_csv("test.csv", index=False)
   data = FileDataStream.read_csv("test.csv",
                                  schema="col=a:R4:0-3 "
                                         "col=b:R4:4-7")
   # In the model file,
   # inputs are two vector with dimension 4
   data.head()
   # transform usage
   xf = TensorFlowScorer(
       model_location=os.path.join(os.path.dirname(__file__), 'frozen_saved_model.pb'),
       columns={'c': ['a', 'b']}
   )

   # fit and transform
   features = xf.fit_transform(data)
   print(features)
   #    a.0  a.1  a.2  a.3  b.0  b.1  b.2  b.3 ...
   # 0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 1  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 2  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 3  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 4  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 5  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 6  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 7  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 8  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...
   # 9  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0 ...

Remarks

The TensorflowTransform extracts the specified outputs from the operations computed on the graph (given the input(s)) using a pre-trained TensorFlow model. The transform takes as input the Tensorflow model together with the names of the inputs to the model and names of the operations for which output values will be extracted from the model.

This transform has the floowing assumptions regarding the input, output and processing of data:

  • The transform currently accepts the

    frozen TensorFlow model as the input.

  • The name of input column(s) should match the name

    of input(s) in Tensorflow model.

  • The name of each output column should match one of the

    operations in the Tensorflow graph.

Methods

get_params

Get the parameters for this operator.

get_params

Get the parameters for this operator.

get_params(deep=False)

Parameters

deep
default value: False