Skip to main content

Struct2Tensor is a package for parsing and manipulating structured data for TensorFlow

Project description

Struct2Tensor

Python PyPI

Introduction

struct2tensor is a library for parsing structured data inside of tensorflow. In particular, it makes it easy to manipulate structured data, e.g., slicing, flattening, copying substructures, and so on, as part of a TensorFlow model graph. The notebook in 'examples/prensor_playground.ipynb' provides a few examples of struct2tensor in action and an introduction to the main concepts. You can run the notebook in your browser through Google's colab environment, or download the file to run it in your own Jupyter environment.

There are two main use cases of this repo:

  1. To create a PIP package. The PIP package contains plug-ins (OpKernels) to an existing tensorflow installation.
  2. To staticlly link with tensorflow-serving.

As these processes are independent, one can follow either set of directions below.

Use a pre-built Linux PIP package.

From a virtual environment, run:

pip install struct2tensor

Nightly Packages

Struct2Tensor 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 struct2tensor

This will install the nightly packages for the major dependencies of struct2tensor such as TensorFlow Metadata (TFMD).

Creating a PIP package.

The struct2tensor PIP package is useful for creating models. It works with tensorflow 2.x.

In order to unify the process, we recommend compiling struct2tensor inside a docker container.

Downloading the Code

Go to your home directory.

Download the source code.

git clone https://github.com/google/struct2tensor.git
cd ~/struct2tensor

Use docker-compose

Install docker-compose.

Use it to build a pip wheel for Python 3.8 with tensorflow version 2:

docker-compose build --build-arg PYTHON_VERSION=3.8 manylinux2014
docker-compose run -e TF_VERSION=RELEASED_TF_2 manylinux2014

This will create a manylinux package in the ~/struct2tensor/dist directory.

Creating a static library

In order to construct a static library for tensorflow-serving, we run:

bazel build -c opt struct2tensor:struct2tensor_kernels_and_ops

This can also be linked into another library.

TensorFlow Serving docker image

struct2tensor needs a couple of custom TensorFlow ops to function. If you train a model with struct2tensor and wants to serve it with TensorFlow Serving, the TensorFlow Serving binary needs to link with those custom ops. We have a pre-built docker image that contains such a binary. The Dockerfile is available at tools/tf_serving_docker/Dockerfile. The image is available at gcr.io/tfx-oss-public/s2t_tf_serving.

Please see the Dockerfile for details. But in brief, the image exposes port 8500 as the gRPC endpoint and port 8501 as the REST endpoint. You can set two environment variables MODEL_BASE_PATH and MODEL_NAME to point it to your model (either mount it to the container, or put your model on GCS). It will look for a saved model at ${MODEL_BASE_PATH}/${MODEL_NAME}/${VERSION_NUMBER}, where VERSION_NUMBER is an integer.

Compatibility

struct2tensor tensorflow
0.45.0 2.13.0
0.44.0 2.12.0
0.43.0 2.11.0
0.42.0 2.10.0
0.41.0 2.9.0
0.40.0 2.9.0
0.39.0 2.8.0
0.38.0 2.8.0
0.37.0 2.7.0
0.36.0 2.7.0
0.35.0 2.6.0
0.34.0 2.6.0
0.33.0 2.5.0
0.32.0 2.5.0
0.31.0 2.5.0
0.30.0 2.4.0
0.29.0 2.4.0
0.28.0 2.4.0
0.27.0 2.4.0
0.26.0 2.3.0
0.25.0 2.3.0
0.24.0 2.3.0
0.23.0 2.3.0
0.22.0 2.2.0
0.21.1 2.1.0
0.21.0 2.1.0
0.0.1.dev* 1.15

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

struct2tensor-0.45.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

struct2tensor-0.45.0-cp310-cp310-macosx_12_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

struct2tensor-0.45.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

struct2tensor-0.45.0-cp39-cp39-macosx_12_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

struct2tensor-0.45.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

struct2tensor-0.45.0-cp38-cp38-macosx_12_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8 macOS 12.0+ x86-64

File details

Details for the file struct2tensor-0.45.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.45.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 dc0049434d942b28ba0fff086c3329cc88af1860a3a8de790846263872a1e46b
MD5 203ed8a5a0a6285ffa8e00ebef4cadc1
BLAKE2b-256 4dfa6498efe383a9fc07e8c07cbd04acb23f7e9e1d3efb4023482a1bfa3f789a

See more details on using hashes here.

File details

Details for the file struct2tensor-0.45.0-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.45.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 72db4c52e27416df1a15c36a32f997bb5455b7df6e45a17a7ffff78748311db5
MD5 5ef25c921ddec6345387a5d6bb839629
BLAKE2b-256 ead44d0e82174e8ae8a1f50e52c037c68c77028caac607382d5e8d3862512978

See more details on using hashes here.

File details

Details for the file struct2tensor-0.45.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.45.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 65df4d668c6e3904bd0fe87624edf13c8ca70aa59daa9911e2d4fcaaacdd04e3
MD5 af2b586ef61af93cfa705654d457c99f
BLAKE2b-256 358b782b4cefc130b07a73db2431ae3eeefbafcfbc375225fca451853c20a373

See more details on using hashes here.

File details

Details for the file struct2tensor-0.45.0-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.45.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 f472e9e5dcf2cf8ab977a17b8a1724e6592891922e5c305b0c079bd3610e3634
MD5 2224ecbb21efd2b4d552aeb00e11c259
BLAKE2b-256 2e586f416e794eac6e0e4b530649b65b2f56d7392bd16c0c2b0c367e3675a1d5

See more details on using hashes here.

File details

Details for the file struct2tensor-0.45.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.45.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 62ee906bb10930a912d11d1c20b60459e5eb1d763e15f969db268138c9aa32ba
MD5 e73c82e13bf80438414b7713c8909ad4
BLAKE2b-256 13835dfd18314d31bea7caea93f3820335a194e64511505d64ddf74ce02d80f7

See more details on using hashes here.

File details

Details for the file struct2tensor-0.45.0-cp38-cp38-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.45.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 e4a68da89e114d18991c02b9a6b330e742c56a010e56463f83e82f0f9821b9ec
MD5 5165eb5940e9a859e3d8a10cce0f3c92
BLAKE2b-256 3ed2c1d7d21205dfe79b590ee41ff05f41f2f78b18ca01234e8e38dce6765d59

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page