Oven logo

Oven

TensorFlow Transform

Python PyPI Documentation

TensorFlow Transform is a library for preprocessing data with TensorFlow. tf.Transform is useful for data that requires a full-pass, such as:

  • Normalize an input value by mean and standard deviation.
  • Convert strings to integers by generating a vocabulary over all input values.
  • Convert floats to integers by assigning them to buckets based on the observed data distribution.

TensorFlow has built-in support for manipulations on a single example or a batch of examples. tf.Transform extends these capabilities to support full-passes over the example data.

The output of tf.Transform is exported as a TensorFlow graph to use for training and serving. Using the same graph for both training and serving can prevent skew since the same transformations are applied in both stages.

For an introduction to tf.Transform, see the tf.Transform section of the TFX Dev Summit talk on TFX (link).

Installation

The tensorflow-transform PyPI package is the recommended way to install tf.Transform:

pip install tensorflow-transform

Build TFT from source

To build from source follow the following steps: Create a virtual environment by running the commands

python3 -m venv <virtualenv_name>
source <virtualenv_name>/bin/activate
pip3 install setuptools wheel
git clone https://github.com/tensorflow/transform.git
cd transform
python3 setup.py bdist_wheel

This will build the TFT wheel in the dist directory. To install the wheel from dist directory run the commands

cd dist
pip3 install tensorflow_transform-<version>-py3-none-any.whl

Nightly Packages

TFT also hosts nightly packages at https://pypi-nightly.tensorflow.org on Google Cloud. To install the latest nightly package, please use the following command:

pip install --extra-index-url https://pypi-nightly.tensorflow.org/simple tensorflow-transform

This will install the nightly packages for the major dependencies of TFT such as TensorFlow Metadata (TFMD), TFX Basic Shared Libraries (TFX-BSL).

Notable Dependencies

TensorFlow is required.

Apache Beam is required; it's the way that efficient distributed computation is supported. By default, Apache Beam runs in local mode but can also run in distributed mode using Google Cloud Dataflow and other Apache Beam runners.

Apache Arrow is also required. TFT uses Arrow to represent data internally in order to make use of vectorized numpy functions.

Compatible versions

The following table is the tf.Transform package versions that are compatible with each other. This is determined by our testing framework, but other untested combinations may also work.

tensorflow-transformapache-beam[gcp]pyarrowtensorflowtensorflow-metadatatfx-bsl
GitHub master2.60.010.0.1nightly (2.x)1.16.11.16.1
1.16.02.60.010.0.12.161.16.11.16.1
1.15.02.47.010.0.02.151.15.01.15.1
1.14.02.47.010.0.02.131.14.01.14.0
1.13.02.41.06.0.02.121.13.11.13.0
1.12.02.41.06.0.02.111.12.01.12.0
1.11.02.41.06.0.01.15.5 / 2.101.11.01.11.0
1.10.02.40.06.0.01.15.5 / 2.91.10.01.10.0
1.9.02.38.05.0.01.15.5 / 2.91.9.01.9.0
1.8.02.38.05.0.01.15.5 / 2.81.8.01.8.0
1.7.02.36.05.0.01.15.5 / 2.81.7.01.7.0
1.6.12.35.05.0.01.15.5 / 2.81.6.01.6.0
1.6.02.35.05.0.01.15.5 / 2.71.6.01.6.0
1.5.02.34.05.0.01.15.2 / 2.71.5.01.5.0
1.4.12.33.04.0.11.15.2 / 2.61.4.01.4.0
1.4.02.33.04.0.11.15.2 / 2.61.4.01.4.0
1.3.02.31.02.0.01.15.2 / 2.61.2.01.3.0
1.2.02.31.02.0.01.15.2 / 2.51.2.01.2.0
1.1.12.29.02.0.01.15.2 / 2.51.1.01.1.1
1.1.02.29.02.0.01.15.2 / 2.51.1.01.1.0
1.0.02.29.02.0.01.15 / 2.51.0.01.0.0
0.30.02.28.02.0.01.15 / 2.40.30.00.30.0
0.29.02.28.02.0.01.15 / 2.40.29.00.29.0
0.28.02.28.02.0.01.15 / 2.40.28.00.28.1
0.27.02.27.02.0.01.15 / 2.40.27.00.27.0
0.26.02.25.00.17.01.15 / 2.30.26.00.26.0
0.25.02.25.00.17.01.15 / 2.30.25.00.25.0
0.24.12.24.00.17.01.15 / 2.30.24.00.24.1
0.24.02.23.00.17.01.15 / 2.30.24.00.24.0
0.23.02.23.00.17.01.15 / 2.30.23.00.23.0
0.22.02.20.00.16.01.15 / 2.20.22.00.22.0
0.21.22.17.00.15.01.15 / 2.10.21.00.21.3
0.21.02.17.00.15.01.15 / 2.10.21.00.21.0
0.15.02.16.00.14.01.15 / 2.00.15.00.15.0
0.14.02.14.00.14.01.140.14.0n/a
0.13.02.11.0n/a1.130.12.1n/a
0.12.02.10.0n/a1.120.12.0n/a
0.11.02.8.0n/a1.110.9.0n/a
0.9.02.6.0n/a1.90.9.0n/a
0.8.02.5.0n/a1.8n/an/a
0.6.02.4.0n/a1.6n/an/a
0.5.02.3.0n/a1.5n/an/a
0.4.02.2.0n/a1.4n/an/a
0.3.12.1.1n/a1.3n/an/a
0.3.02.1.1n/a1.3n/an/a
0.1.102.0.0n/a1.0n/an/a

Questions

Please direct any questions about working with tf.Transform to Stack Overflow using the tensorflow-transform tag.