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.7 with tensorflow version 2:

docker-compose build --build-arg PYTHON_VERSION=3.7 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.40.0 2.8.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.40.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

struct2tensor-0.40.0-cp39-cp39-macosx_10_14_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

struct2tensor-0.40.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

struct2tensor-0.40.0-cp38-cp38-macosx_10_9_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

struct2tensor-0.40.0-cp37-cp37m-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

struct2tensor-0.40.0-cp37-cp37m-macosx_10_9_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for struct2tensor-0.40.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ab2556cacaaa48117b11cd4da9a48e062f36c1e4b3f6c3d184867d58039c9d52
MD5 d9bc2bcce2fc0c6e5d2c45305f00b1d7
BLAKE2b-256 e233f52a2f5acb52f4487803d97e9f4abbcd370c68b5909ea51c694811e6a0c1

See more details on using hashes here.

File details

Details for the file struct2tensor-0.40.0-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.40.0-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 9cc777df9861f912af223a2d1bb05299db6fa5266ee6eb3afd0dd1e2d081ea69
MD5 64ce4276ad9bf133354019b2659ca99b
BLAKE2b-256 abda1dc879f0f7e6b02b13e8c4f1846eeaba17a0e0c2345519304a3fc63e42c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for struct2tensor-0.40.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d60f18840dc437d21849dd94eee7f60f93586312933018d61cb9acff78371892
MD5 44c5c6a4220dfe3b69e2cbf6dfc23d2e
BLAKE2b-256 0ad7c67ce84c0b42d94acd72dd06d6e88e9fe2d28b0bc542e3d3c284fe6415a2

See more details on using hashes here.

File details

Details for the file struct2tensor-0.40.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.40.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7f68fa92845d265550a7302ff0a2e727e28893d97f800113f7120d9e77fd0116
MD5 4ea4d5b76325bf0968ac313963bd9a60
BLAKE2b-256 7baa87bc7fa0086297f6936c93323bc774ab59771a8ead3ea7c743499736e7d5

See more details on using hashes here.

File details

Details for the file struct2tensor-0.40.0-cp37-cp37m-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.40.0-cp37-cp37m-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 cf5bbd8792720bcea645e8e3db08b10811b458a959e0bade8bcd9f55b026fef6
MD5 c80d927b772c9ef7bfee4ffc97e5c8d3
BLAKE2b-256 09436dc30e9e2ed10f9dcb3e510f09b838f7dbd6180d508543fc364b7d012aed

See more details on using hashes here.

File details

Details for the file struct2tensor-0.40.0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for struct2tensor-0.40.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1e19ce96fcf5c50e938a27f4f51d73c35f0cb26100c807f9b61dc1119fdb0d8c
MD5 4513601665ccd7c10ce034a2341df7b4
BLAKE2b-256 4f862c78b50ae43d0b85540dee0055dd223bbab4fb34b3c63b530ce19c015a60

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