{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "24gYiJcWNlpA"
},
"source": [
"##### Copyright 2020 The TensorFlow Authors."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:07:38.310706Z",
"iopub.status.busy": "2024-08-02T09:07:38.310469Z",
"iopub.status.idle": "2024-08-02T09:07:38.314333Z",
"shell.execute_reply": "2024-08-02T09:07:38.313751Z"
},
"id": "ioaprt5q5US7"
},
"outputs": [],
"source": [
"#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ItXfxkxvosLH"
},
"source": [
"# Graph-based Neural Structured Learning in TFX\n",
"\n",
"This tutorial describes graph regularization from the\n",
"[Neural Structured Learning](https://www.tensorflow.org/neural_structured_learning/)\n",
"framework and demonstrates an end-to-end workflow for sentiment classification\n",
"in a TFX pipeline."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "vyAF26z9IDoq"
},
"source": [
"Note: We recommend running this tutorial in a Colab notebook, with no setup required! Just click \"Run in Google Colab\".\n",
"\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-niht8EPmUUl"
},
"source": [
"> Warning: Estimators are not recommended for new code. Estimators run v1.Session
-style code which is more difficult to write correctly, and can behave unexpectedly, especially when combined with TF 2 code. Estimators do fall under our [compatibility guarantees](https://tensorflow.org/guide/versions), but will receive no fixes other than security vulnerabilities. See the [migration guide](https://tensorflow.org/guide/migrate) for details."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "z3otbdCMmJiJ"
},
"source": [
"## Overview"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ApxPtg2DiTtd"
},
"source": [
"This notebook classifies movie reviews as *positive* or *negative* using the\n",
"text of the review. This is an example of *binary* classification, an important\n",
"and widely applicable kind of machine learning problem.\n",
"\n",
"We will demonstrate the use of graph regularization in this notebook by building\n",
"a graph from the given input. The general recipe for building a\n",
"graph-regularized model using the Neural Structured Learning (NSL) framework\n",
"when the input does not contain an explicit graph is as follows:\n",
"\n",
"1. Create embeddings for each text sample in the input. This can be done using\n",
" pre-trained models such as [word2vec](https://arxiv.org/pdf/1310.4546.pdf),\n",
" [Swivel](https://arxiv.org/abs/1602.02215),\n",
" [BERT](https://arxiv.org/abs/1810.04805) etc.\n",
"2. Build a graph based on these embeddings by using a similarity metric such as\n",
" the 'L2' distance, 'cosine' distance, etc. Nodes in the graph correspond to\n",
" samples and edges in the graph correspond to similarity between pairs of\n",
" samples.\n",
"3. Generate training data from the above synthesized graph and sample features.\n",
" The resulting training data will contain neighbor features in addition to\n",
" the original node features.\n",
"4. Create a neural network as a base model using Estimators.\n",
"5. Wrap the base model with the `add_graph_regularization` wrapper function,\n",
" which is provided by the NSL framework, to create a new graph Estimator\n",
" model. This new model will include a graph regularization loss as the\n",
" regularization term in its training objective.\n",
"6. Train and evaluate the graph Estimator model.\n",
"\n",
"In this tutorial, we integrate the above workflow in a TFX pipeline using\n",
"several custom TFX components as well as a custom graph-regularized trainer\n",
"component.\n",
"\n",
"Below is the schematic for our TFX pipeline. Orange boxes represent\n",
"off-the-shelf TFX components and pink boxes represent custom TFX components.\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "EIx0r9-TeVQQ"
},
"source": [
"## Upgrade Pip\n",
"\n",
"To avoid upgrading Pip in a system when running locally, check to make sure that we're running in Colab. Local systems can of course be upgraded separately."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:07:38.317949Z",
"iopub.status.busy": "2024-08-02T09:07:38.317705Z",
"iopub.status.idle": "2024-08-02T09:07:38.325478Z",
"shell.execute_reply": "2024-08-02T09:07:38.324892Z"
},
"id": "-UmVrHUfkUA2"
},
"outputs": [],
"source": [
"import sys\n",
"if 'google.colab' in sys.modules:\n",
" !pip install --upgrade pip"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nDOFbB34KY1R"
},
"source": [
"## Install Required Packages"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:07:38.328566Z",
"iopub.status.busy": "2024-08-02T09:07:38.328337Z",
"iopub.status.idle": "2024-08-02T09:07:41.231608Z",
"shell.execute_reply": "2024-08-02T09:07:41.230415Z"
},
"id": "yDUe7gk_ztZ-"
},
"outputs": [],
"source": [
"# TFX has a constraint of 1.16 due to the removal of tf.estimator support.\n",
"!pip install -q \\\n",
" \"tfx<1.16\" \\\n",
" neural-structured-learning \\\n",
" tensorflow-hub \\\n",
" tensorflow-datasets"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "1CeGS8G_eueJ"
},
"source": [
"## Did you restart the runtime?\n",
"\n",
"If you are using Google Colab, the first time that you run the cell above, you must restart the runtime (Runtime > Restart runtime ...). This is because of the way that Colab loads packages."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "x6FJ64qMNLez"
},
"source": [
"## Dependencies and imports"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:07:41.236323Z",
"iopub.status.busy": "2024-08-02T09:07:41.236045Z",
"iopub.status.idle": "2024-08-02T09:07:46.762213Z",
"shell.execute_reply": "2024-08-02T09:07:46.761493Z"
},
"id": "2ew7HTbPpCJH"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-08-02 09:07:42.541870: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n",
"2024-08-02 09:07:42.541914: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n",
"2024-08-02 09:07:42.543415: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"TF Version: 2.15.1\n",
"Eager mode: True\n",
"GPU is available\n",
"NSL Version: 1.4.0\n",
"TFX Version: 1.15.1\n",
"TFDV version: 1.15.1\n",
"TFT version: 1.15.0\n",
"TFMA version: 0.46.0\n",
"Hub version: 0.15.0\n",
"Beam version: 2.57.0\n"
]
}
],
"source": [
"import apache_beam as beam\n",
"import gzip as gzip_lib\n",
"import numpy as np\n",
"import os\n",
"import pprint\n",
"import shutil\n",
"import tempfile\n",
"import urllib\n",
"import uuid\n",
"pp = pprint.PrettyPrinter()\n",
"\n",
"import tensorflow as tf\n",
"import neural_structured_learning as nsl\n",
"\n",
"import tfx\n",
"from tfx.components.evaluator.component import Evaluator\n",
"from tfx.components.example_gen.import_example_gen.component import ImportExampleGen\n",
"from tfx.components.example_validator.component import ExampleValidator\n",
"from tfx.components.model_validator.component import ModelValidator\n",
"from tfx.components.pusher.component import Pusher\n",
"from tfx.components.schema_gen.component import SchemaGen\n",
"from tfx.components.statistics_gen.component import StatisticsGen\n",
"from tfx.components.trainer import executor as trainer_executor\n",
"from tfx.components.trainer.component import Trainer\n",
"from tfx.components.transform.component import Transform\n",
"from tfx.dsl.components.base import executor_spec\n",
"from tfx.orchestration.experimental.interactive.interactive_context import InteractiveContext\n",
"from tfx.proto import evaluator_pb2\n",
"from tfx.proto import example_gen_pb2\n",
"from tfx.proto import pusher_pb2\n",
"from tfx.proto import trainer_pb2\n",
"\n",
"from tfx.types import artifact\n",
"from tfx.types import artifact_utils\n",
"from tfx.types import channel\n",
"from tfx.types import standard_artifacts\n",
"from tfx.types.standard_artifacts import Examples\n",
"\n",
"from tfx.dsl.component.experimental.annotations import InputArtifact\n",
"from tfx.dsl.component.experimental.annotations import OutputArtifact\n",
"from tfx.dsl.component.experimental.annotations import Parameter\n",
"from tfx.dsl.component.experimental.decorators import component\n",
"\n",
"from tensorflow_metadata.proto.v0 import anomalies_pb2\n",
"from tensorflow_metadata.proto.v0 import schema_pb2\n",
"from tensorflow_metadata.proto.v0 import statistics_pb2\n",
"\n",
"import tensorflow_data_validation as tfdv\n",
"import tensorflow_transform as tft\n",
"import tensorflow_model_analysis as tfma\n",
"import tensorflow_hub as hub\n",
"import tensorflow_datasets as tfds\n",
"\n",
"print(\"TF Version: \", tf.__version__)\n",
"print(\"Eager mode: \", tf.executing_eagerly())\n",
"print(\n",
" \"GPU is\",\n",
" \"available\" if tf.config.list_physical_devices(\"GPU\") else \"NOT AVAILABLE\")\n",
"print(\"NSL Version: \", nsl.__version__)\n",
"print(\"TFX Version: \", tfx.__version__)\n",
"print(\"TFDV version: \", tfdv.__version__)\n",
"print(\"TFT version: \", tft.__version__)\n",
"print(\"TFMA version: \", tfma.__version__)\n",
"print(\"Hub version: \", hub.__version__)\n",
"print(\"Beam version: \", beam.__version__)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nGwwFd99n42P"
},
"source": [
"## IMDB dataset\n",
"\n",
"The\n",
"[IMDB dataset](https://www.tensorflow.org/datasets/catalog/imdb_reviews)\n",
"contains the text of 50,000 movie reviews from the\n",
"[Internet Movie Database](https://www.imdb.com/). These are split into 25,000\n",
"reviews for training and 25,000 reviews for testing. The training and testing\n",
"sets are *balanced*, meaning they contain an equal number of positive and\n",
"negative reviews.\n",
"Moreover, there are 50,000 additional unlabeled movie reviews."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "iAsKG535pHep"
},
"source": [
"### Download preprocessed IMDB dataset\n",
"\n",
"The following code downloads the IMDB dataset (or uses a cached copy if it has already been downloaded) using TFDS. To speed up this notebook we will use only 10,000 labeled reviews and 10,000 unlabeled reviews for training, and 10,000 test reviews for evaluation."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:07:46.766021Z",
"iopub.status.busy": "2024-08-02T09:07:46.765425Z",
"iopub.status.idle": "2024-08-02T09:07:49.858380Z",
"shell.execute_reply": "2024-08-02T09:07:49.857613Z"
},
"id": "__cZi2Ic48KL"
},
"outputs": [],
"source": [
"train_set, eval_set = tfds.load(\n",
" \"imdb_reviews:1.0.0\",\n",
" split=[\"train[:10000]+unsupervised[:10000]\", \"test[:10000]\"],\n",
" shuffle_files=False)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nE9tNh-67Y3W"
},
"source": [
"Let's look at a few reviews from the training set:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:07:49.862670Z",
"iopub.status.busy": "2024-08-02T09:07:49.862271Z",
"iopub.status.idle": "2024-08-02T09:07:50.949797Z",
"shell.execute_reply": "2024-08-02T09:07:50.948786Z"
},
"id": "LsnHde8T67Jz"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Review: This was an absolutely terrible movie. Don't be lured in by Christopher Walken or Michael Ironside. Both are great actors, but this must simply be their worst role in history. Even their great acting could not redeem this movie's ridiculous storyline. This movie is an early nineties US propaganda pi\n",
"Label: 0\n",
"\n",
"Review: I have been known to fall asleep during films, but this is usually due to a combination of things including, really tired, being warm and comfortable on the sette and having just eaten a lot. However on this occasion I fell asleep because the film was rubbish. The plot development was constant. Cons\n",
"Label: 0\n",
"\n",
"Review: Mann photographs the Alberta Rocky Mountains in a superb fashion, and Jimmy Stewart and Walter Brennan give enjoyable performances as they always seem to do.
But come on Hollywood - a Mountie telling the people of Dawson City, Yukon to elect themselves a marshal (yes a marshal!) and to e\n",
"Label: 0\n",
"\n",
"Review: This is the kind of film for a snowy Sunday afternoon when the rest of the world can go ahead with its own business as you descend into a big arm-chair and mellow for a couple of hours. Wonderful performances from Cher and Nicolas Cage (as always) gently row the plot along. There are no rapids to cr\n",
"Label: 1\n",
"\n"
]
}
],
"source": [
"for tfrecord in train_set.take(4):\n",
" print(\"Review: {}\".format(tfrecord[\"text\"].numpy().decode(\"utf-8\")[:300]))\n",
" print(\"Label: {}\\n\".format(tfrecord[\"label\"].numpy()))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:07:50.953860Z",
"iopub.status.busy": "2024-08-02T09:07:50.953583Z",
"iopub.status.idle": "2024-08-02T09:08:00.140606Z",
"shell.execute_reply": "2024-08-02T09:08:00.139753Z"
},
"id": "0wG7v3rk-Cwo"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmpfs/tmp/ipykernel_9764/2578414870.py:7: DeprecationWarning: Converting `np.integer` or `np.signedinteger` to a dtype is deprecated. The current result is `np.dtype(np.int_)` which is not strictly correct. Note that the result depends on the system. To ensure stable results use may want to use `np.int64` or `np.int32`.\n",
" elif value.dtype == np.integer:\n"
]
}
],
"source": [
"def _dict_to_example(instance):\n",
" \"\"\"Decoded CSV to tf example.\"\"\"\n",
" feature = {}\n",
" for key, value in instance.items():\n",
" if value is None:\n",
" feature[key] = tf.train.Feature()\n",
" elif value.dtype == np.integer:\n",
" feature[key] = tf.train.Feature(\n",
" int64_list=tf.train.Int64List(value=value.tolist()))\n",
" elif value.dtype == np.float32:\n",
" feature[key] = tf.train.Feature(\n",
" float_list=tf.train.FloatList(value=value.tolist()))\n",
" else:\n",
" feature[key] = tf.train.Feature(\n",
" bytes_list=tf.train.BytesList(value=value.tolist()))\n",
" return tf.train.Example(features=tf.train.Features(feature=feature))\n",
"\n",
"\n",
"examples_path = tempfile.mkdtemp(prefix=\"tfx-data\")\n",
"train_path = os.path.join(examples_path, \"train.tfrecord\")\n",
"eval_path = os.path.join(examples_path, \"eval.tfrecord\")\n",
"\n",
"for path, dataset in [(train_path, train_set), (eval_path, eval_set)]:\n",
" with tf.io.TFRecordWriter(path) as writer:\n",
" for example in dataset:\n",
" writer.write(\n",
" _dict_to_example({\n",
" \"label\": np.array([example[\"label\"].numpy()]),\n",
" \"text\": np.array([example[\"text\"].numpy()]),\n",
" }).SerializeToString())"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "HdQWxfsVkzdJ"
},
"source": [
"## Run TFX Components Interactively\n",
"\n",
"In the cells that follow you will construct TFX components and run each one interactively within the InteractiveContext to obtain `ExecutionResult` objects. This mirrors the process of an orchestrator running components in a TFX DAG based on when the dependencies for each component are met."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:00.144561Z",
"iopub.status.busy": "2024-08-02T09:08:00.144272Z",
"iopub.status.idle": "2024-08-02T09:08:00.151071Z",
"shell.execute_reply": "2024-08-02T09:08:00.150496Z"
},
"id": "4aVuXUil7hil"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:InteractiveContext pipeline_root argument not provided: using temporary directory /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3 as root for pipeline outputs.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:InteractiveContext metadata_connection_config not provided: using SQLite ML Metadata database at /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/metadata.sqlite.\n"
]
}
],
"source": [
"context = InteractiveContext()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "L9fwt9gQk3BR"
},
"source": [
"### The ExampleGen Component\n",
"In any ML development process the first step when starting code development is to ingest the training and test datasets. The `ExampleGen` component brings data into the TFX pipeline.\n",
"\n",
"Create an ExampleGen component and run it."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:00.154164Z",
"iopub.status.busy": "2024-08-02T09:08:00.153947Z",
"iopub.status.idle": "2024-08-02T09:08:07.037846Z",
"shell.execute_reply": "2024-08-02T09:08:07.037213Z"
},
"id": "WdH4ql3Y7pT4"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:apache_beam.runners.interactive.interactive_environment:Dependencies required for Interactive Beam PCollection visualization are not available, please use: `pip install apache-beam[interactive]` to install necessary dependencies to enable all data visualization features.\n"
]
},
{
"data": {
"application/javascript": [
"\n",
" if (typeof window.interactive_beam_jquery == 'undefined') {\n",
" var jqueryScript = document.createElement('script');\n",
" jqueryScript.src = 'https://code.jquery.com/jquery-3.4.1.slim.min.js';\n",
" jqueryScript.type = 'text/javascript';\n",
" jqueryScript.onload = function() {\n",
" var datatableScript = document.createElement('script');\n",
" datatableScript.src = 'https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js';\n",
" datatableScript.type = 'text/javascript';\n",
" datatableScript.onload = function() {\n",
" window.interactive_beam_jquery = jQuery.noConflict(true);\n",
" window.interactive_beam_jquery(document).ready(function($){\n",
" \n",
" });\n",
" }\n",
" document.head.appendChild(datatableScript);\n",
" };\n",
" document.head.appendChild(jqueryScript);\n",
" } else {\n",
" window.interactive_beam_jquery(document).ready(function($){\n",
" \n",
" });\n",
" }"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:apache_beam.io.tfrecordio:Couldn't find python-snappy so the implementation of _TFRecordUtil._masked_crc32c is not as fast as it could be.\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f13b8245610
.execution_id | 1 |
.component | \n",
"\n",
"ImportExampleGen at 0x7f139ecd9520 .inputs | {} | .outputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12502e0b20 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1) at 0x7f12502da550 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
| .exec_properties | ['input_base'] | /tmpfs/tmp/tfx-datamm2ufe7s | ['input_config'] | {\n",
" "splits": [\n",
" {\n",
" "name": "train",\n",
" "pattern": "train.tfrecord"\n",
" },\n",
" {\n",
" "name": "eval",\n",
" "pattern": "eval.tfrecord"\n",
" }\n",
" ]\n",
"} | ['output_config'] | {} | ['output_data_format'] | 6 | ['output_file_format'] | 5 | ['custom_config'] | None | ['range_config'] | None | ['span'] | 0 | ['version'] | None | ['input_fingerprint'] | split:train,num_files:1,total_bytes:27706811,xor_checksum:1722589677,sum_checksum:1722589677\n",
"split:eval,num_files:1,total_bytes:13374744,xor_checksum:1722589680,sum_checksum:1722589680 |
|
|
.component.inputs | {} |
.component.outputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12502e0b20 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1) at 0x7f12502da550 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: ImportExampleGen\n",
" execution_id: 1\n",
" outputs:\n",
" examples: OutputChannel(artifact_type=Examples, producer_component_id=ImportExampleGen, output_key=examples, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"input_config = example_gen_pb2.Input(splits=[\n",
" example_gen_pb2.Input.Split(name='train', pattern='train.tfrecord'),\n",
" example_gen_pb2.Input.Split(name='eval', pattern='eval.tfrecord')\n",
"])\n",
"\n",
"example_gen = ImportExampleGen(input_base=examples_path, input_config=input_config)\n",
"\n",
"context.run(example_gen, enable_cache=True)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:07.041528Z",
"iopub.status.busy": "2024-08-02T09:08:07.041277Z",
"iopub.status.idle": "2024-08-02T09:08:07.045717Z",
"shell.execute_reply": "2024-08-02T09:08:07.045144Z"
},
"id": "IeUp6xCCrxsS"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Artifact(artifact: id: 1\n",
"type_id: 14\n",
"uri: \"/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1\"\n",
"properties {\n",
" key: \"split_names\"\n",
" value {\n",
" string_value: \"[\\\"train\\\", \\\"eval\\\"]\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"file_format\"\n",
" value {\n",
" string_value: \"tfrecords_gzip\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"input_fingerprint\"\n",
" value {\n",
" string_value: \"split:train,num_files:1,total_bytes:27706811,xor_checksum:1722589677,sum_checksum:1722589677\\nsplit:eval,num_files:1,total_bytes:13374744,xor_checksum:1722589680,sum_checksum:1722589680\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"payload_format\"\n",
" value {\n",
" string_value: \"FORMAT_TF_EXAMPLE\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"span\"\n",
" value {\n",
" int_value: 0\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"tfx_version\"\n",
" value {\n",
" string_value: \"1.15.1\"\n",
" }\n",
"}\n",
"state: LIVE\n",
", artifact_type: id: 14\n",
"name: \"Examples\"\n",
"properties {\n",
" key: \"span\"\n",
" value: INT\n",
"}\n",
"properties {\n",
" key: \"split_names\"\n",
" value: STRING\n",
"}\n",
"properties {\n",
" key: \"version\"\n",
" value: INT\n",
"}\n",
"base_type: DATASET\n",
")\n",
"\n",
"example_gen.outputs is a \n",
"{'examples': OutputChannel(artifact_type=Examples, producer_component_id=ImportExampleGen, output_key=examples, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)}\n",
"[\"train\", \"eval\"]\n"
]
}
],
"source": [
"for artifact in example_gen.outputs['examples'].get():\n",
" print(artifact)\n",
"\n",
"print('\\nexample_gen.outputs is a {}'.format(type(example_gen.outputs)))\n",
"print(example_gen.outputs)\n",
"\n",
"print(example_gen.outputs['examples'].get()[0].split_names)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0SXc2OGnDWz5"
},
"source": [
"The component's outputs include 2 artifacts:\n",
"* the training examples (10,000 labeled reviews + 10,000 unlabeled reviews)\n",
"* the eval examples (10,000 labeled reviews)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "pcPppPASQzFa"
},
"source": [
"### The IdentifyExamples Custom Component\n",
"To use NSL, we will need each instance to have a unique ID. We create a custom\n",
"component that adds such a unique ID to all instances across all splits. We\n",
"leverage [Apache Beam](https://beam.apache.org) to be able to easily scale to\n",
"large datasets if needed."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:07.048967Z",
"iopub.status.busy": "2024-08-02T09:08:07.048748Z",
"iopub.status.idle": "2024-08-02T09:08:07.057021Z",
"shell.execute_reply": "2024-08-02T09:08:07.056453Z"
},
"id": "XHCUzXA5qeWe"
},
"outputs": [],
"source": [
"def make_example_with_unique_id(example, id_feature_name):\n",
" \"\"\"Adds a unique ID to the given `tf.train.Example` proto.\n",
"\n",
" This function uses Python's 'uuid' module to generate a universally unique\n",
" identifier for each example.\n",
"\n",
" Args:\n",
" example: An instance of a `tf.train.Example` proto.\n",
" id_feature_name: The name of the feature in the resulting `tf.train.Example`\n",
" that will contain the unique identifier.\n",
"\n",
" Returns:\n",
" A new `tf.train.Example` proto that includes a unique identifier as an\n",
" additional feature.\n",
" \"\"\"\n",
" result = tf.train.Example()\n",
" result.CopyFrom(example)\n",
" unique_id = uuid.uuid4()\n",
" result.features.feature.get_or_create(\n",
" id_feature_name).bytes_list.MergeFrom(\n",
" tf.train.BytesList(value=[str(unique_id).encode('utf-8')]))\n",
" return result\n",
"\n",
"\n",
"@component\n",
"def IdentifyExamples(orig_examples: InputArtifact[Examples],\n",
" identified_examples: OutputArtifact[Examples],\n",
" id_feature_name: Parameter[str],\n",
" component_name: Parameter[str]) -> None:\n",
"\n",
" # Get a list of the splits in input_data\n",
" splits_list = artifact_utils.decode_split_names(\n",
" split_names=orig_examples.split_names)\n",
" # For completeness, encode the splits names and payload_format.\n",
" # We could also just use input_data.split_names.\n",
" identified_examples.split_names = artifact_utils.encode_split_names(\n",
" splits=splits_list)\n",
" # TODO(b/168616829): Remove populating payload_format after tfx 0.25.0.\n",
" identified_examples.set_string_custom_property(\n",
" \"payload_format\",\n",
" orig_examples.get_string_custom_property(\"payload_format\"))\n",
"\n",
"\n",
" for split in splits_list:\n",
" input_dir = artifact_utils.get_split_uri([orig_examples], split)\n",
" output_dir = artifact_utils.get_split_uri([identified_examples], split)\n",
" os.mkdir(output_dir)\n",
" with beam.Pipeline() as pipeline:\n",
" (pipeline\n",
" | 'ReadExamples' >> beam.io.ReadFromTFRecord(\n",
" os.path.join(input_dir, '*'),\n",
" coder=beam.coders.coders.ProtoCoder(tf.train.Example))\n",
" | 'AddUniqueId' >> beam.Map(make_example_with_unique_id, id_feature_name)\n",
" | 'WriteIdentifiedExamples' >> beam.io.WriteToTFRecord(\n",
" file_path_prefix=os.path.join(output_dir, 'data_tfrecord'),\n",
" coder=beam.coders.coders.ProtoCoder(tf.train.Example),\n",
" file_name_suffix='.gz'))\n",
"\n",
" return"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:07.059799Z",
"iopub.status.busy": "2024-08-02T09:08:07.059538Z",
"iopub.status.idle": "2024-08-02T09:08:14.796566Z",
"shell.execute_reply": "2024-08-02T09:08:14.795798Z"
},
"id": "ZtLxNWHPO0je"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f12205bc1c0
.execution_id | 2 |
.component | \n",
"\n",
"IdentifyExamples at 0x7f12202ee1c0 .inputs | ['orig_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12502e0b20 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1) at 0x7f12502da550 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
| .outputs | ['identified_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
| .exec_properties | ['id_feature_name'] | id | ['component_name'] | IdentifyExamples |
|
|
.component.inputs | ['orig_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12502e0b20 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1) at 0x7f12502da550 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ImportExampleGen/examples/1 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
|
.component.outputs | ['identified_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: IdentifyExamples\n",
" execution_id: 2\n",
" outputs:\n",
" identified_examples: OutputChannel(artifact_type=Examples, producer_component_id=IdentifyExamples, output_key=identified_examples, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"identify_examples = IdentifyExamples(\n",
" orig_examples=example_gen.outputs['examples'],\n",
" component_name=u'IdentifyExamples',\n",
" id_feature_name=u'id')\n",
"context.run(identify_examples, enable_cache=False)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "csM6BFhtk5Aa"
},
"source": [
"### The StatisticsGen Component\n",
"\n",
"The `StatisticsGen` component computes descriptive statistics for your dataset. The statistics that it generates can be visualized for review, and are used for example validation and to infer a schema.\n",
"\n",
"Create a StatisticsGen component and run it."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:14.800455Z",
"iopub.status.busy": "2024-08-02T09:08:14.800142Z",
"iopub.status.idle": "2024-08-02T09:08:21.224282Z",
"shell.execute_reply": "2024-08-02T09:08:21.223611Z"
},
"id": "MAscCCYWgA-9"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f12502daf10
.execution_id | 3 |
.component | \n",
"\n",
"StatisticsGen at 0x7f12202ee220 .inputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
| .outputs | ['statistics'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f12202ee7c0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3) at 0x7f122032e460 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3 | .span | 0 | .split_names | ["train", "eval"] |
|
|
|
| .exec_properties | ['stats_options_json'] | None | ['exclude_splits'] | [] |
|
|
.component.inputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
|
.component.outputs | ['statistics'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f12202ee7c0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3) at 0x7f122032e460 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3 | .span | 0 | .split_names | ["train", "eval"] |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: StatisticsGen\n",
" execution_id: 3\n",
" outputs:\n",
" statistics: OutputChannel(artifact_type=ExampleStatistics, producer_component_id=StatisticsGen, output_key=statistics, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Computes statistics over data for visualization and example validation.\n",
"statistics_gen = StatisticsGen(\n",
" examples=identify_examples.outputs[\"identified_examples\"])\n",
"context.run(statistics_gen, enable_cache=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "HLKLTO9Nk60p"
},
"source": [
"### The SchemaGen Component\n",
"\n",
"The `SchemaGen` component generates a schema for your data based on the statistics from StatisticsGen. It tries to infer the data types of each of your features, and the ranges of legal values for categorical features.\n",
"\n",
"Create a SchemaGen component and run it."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:21.228192Z",
"iopub.status.busy": "2024-08-02T09:08:21.227940Z",
"iopub.status.idle": "2024-08-02T09:08:21.285676Z",
"shell.execute_reply": "2024-08-02T09:08:21.285077Z"
},
"id": "ygQvZ6hsiQ_J"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f1268060a00
.execution_id | 4 |
.component | \n",
"\n",
"SchemaGen at 0x7f11fc084be0 .inputs | ['statistics'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f12202ee7c0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3) at 0x7f122032e460 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3 | .span | 0 | .split_names | ["train", "eval"] |
|
|
|
| .outputs | ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
| .exec_properties | ['infer_feature_shape'] | 0 | ['exclude_splits'] | [] |
|
|
.component.inputs | ['statistics'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f12202ee7c0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3) at 0x7f122032e460 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3 | .span | 0 | .split_names | ["train", "eval"] |
|
|
|
|
.component.outputs | ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: SchemaGen\n",
" execution_id: 4\n",
" outputs:\n",
" schema: OutputChannel(artifact_type=Schema, producer_component_id=SchemaGen, output_key=schema, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Generates schema based on statistics files.\n",
"schema_gen = SchemaGen(\n",
" statistics=statistics_gen.outputs['statistics'], infer_feature_shape=False)\n",
"context.run(schema_gen, enable_cache=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "kdtU3u01FR-2"
},
"source": [
"The generated artifact is just a `schema.pbtxt` containing a text representation of a `schema_pb2.Schema` protobuf:"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:21.289024Z",
"iopub.status.busy": "2024-08-02T09:08:21.288780Z",
"iopub.status.idle": "2024-08-02T09:08:21.293863Z",
"shell.execute_reply": "2024-08-02T09:08:21.293235Z"
},
"id": "L6-tgKi6A_gK"
},
"outputs": [],
"source": [
"train_uri = schema_gen.outputs['schema'].get()[0].uri\n",
"schema_filename = os.path.join(train_uri, 'schema.pbtxt')\n",
"schema = tfx.utils.io_utils.parse_pbtxt_file(\n",
" file_name=schema_filename, message=schema_pb2.Schema())"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "FaSgx5qIFelw"
},
"source": [
"It can be visualized using `tfdv.display_schema()` (we will look at this in more detail in a subsequent lab):"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:21.297316Z",
"iopub.status.busy": "2024-08-02T09:08:21.296762Z",
"iopub.status.idle": "2024-08-02T09:08:21.308956Z",
"shell.execute_reply": "2024-08-02T09:08:21.308350Z"
},
"id": "gycOsJIQFhi3"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Type | \n",
" Presence | \n",
" Valency | \n",
" Domain | \n",
"
\n",
" \n",
" Feature name | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 'id' | \n",
" BYTES | \n",
" required | \n",
" single | \n",
" - | \n",
"
\n",
" \n",
" 'label' | \n",
" INT | \n",
" required | \n",
" single | \n",
" - | \n",
"
\n",
" \n",
" 'text' | \n",
" BYTES | \n",
" required | \n",
" single | \n",
" - | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Type Presence Valency Domain\n",
"Feature name \n",
"'id' BYTES required single -\n",
"'label' INT required single -\n",
"'text' BYTES required single -"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"tfdv.display_schema(schema)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "V1qcUuO9k9f8"
},
"source": [
"### The ExampleValidator Component\n",
"\n",
"The `ExampleValidator` performs anomaly detection, based on the statistics from StatisticsGen and the schema from SchemaGen. It looks for problems such as missing values, values of the wrong type, or categorical values outside of the domain of acceptable values.\n",
"\n",
"Create an ExampleValidator component and run it."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:21.312490Z",
"iopub.status.busy": "2024-08-02T09:08:21.311873Z",
"iopub.status.idle": "2024-08-02T09:08:21.363618Z",
"shell.execute_reply": "2024-08-02T09:08:21.363002Z"
},
"id": "XRlRUuGgiXks"
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f126a037340
.execution_id | 5 |
.component | \n",
"\n",
"ExampleValidator at 0x7f11fc0841c0 .inputs | ['statistics'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f12202ee7c0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3) at 0x7f122032e460 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3 | .span | 0 | .split_names | ["train", "eval"] |
|
|
| ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
| .outputs | ['anomalies'] | \n",
"\n",
"Channel of type 'ExampleAnomalies' (1 artifact) at 0x7f11fc07af40 .type_name | ExampleAnomalies | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleAnomalies' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ExampleValidator/anomalies/5) at 0x7f11fc07f940 .type | <class 'tfx.types.standard_artifacts.ExampleAnomalies'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ExampleValidator/anomalies/5 | .span | 0 | .split_names | ["train", "eval"] |
|
|
|
| .exec_properties | ['exclude_splits'] | [] | ['custom_validation_config'] | None |
|
|
.component.inputs | ['statistics'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f12202ee7c0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3) at 0x7f122032e460 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/StatisticsGen/statistics/3 | .span | 0 | .split_names | ["train", "eval"] |
|
|
| ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
|
.component.outputs | ['anomalies'] | \n",
"\n",
"Channel of type 'ExampleAnomalies' (1 artifact) at 0x7f11fc07af40 .type_name | ExampleAnomalies | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleAnomalies' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ExampleValidator/anomalies/5) at 0x7f11fc07f940 .type | <class 'tfx.types.standard_artifacts.ExampleAnomalies'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/ExampleValidator/anomalies/5 | .span | 0 | .split_names | ["train", "eval"] |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: ExampleValidator\n",
" execution_id: 5\n",
" outputs:\n",
" anomalies: OutputChannel(artifact_type=ExampleAnomalies, producer_component_id=ExampleValidator, output_key=anomalies, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Performs anomaly detection based on statistics and data schema.\n",
"validate_stats = ExampleValidator(\n",
" statistics=statistics_gen.outputs['statistics'],\n",
" schema=schema_gen.outputs['schema'])\n",
"context.run(validate_stats, enable_cache=False)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "g3f2vmrF_e9b"
},
"source": [
"### The SynthesizeGraph Component"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3oCuXo4BPfGr"
},
"source": [
"Graph construction involves creating embeddings for text samples and then using\n",
"a similarity function to compare the embeddings."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Gf8B3KxcinZ0"
},
"source": [
"We will use pretrained Swivel embeddings to create embeddings in the\n",
"`tf.train.Example` format for each sample in the input. We will store the\n",
"resulting embeddings in the `TFRecord` format along with the sample's ID.\n",
"This is important and will allow us match sample embeddings with corresponding\n",
"nodes in the graph later."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "_hSzZNdbPa4X"
},
"source": [
"Once we have the sample embeddings, we will use them to build a similarity\n",
"graph, i.e, nodes in this graph will correspond to samples and edges in this\n",
"graph will correspond to similarity between pairs of nodes.\n",
"\n",
"Neural Structured Learning provides a graph building library to build a graph\n",
"based on sample embeddings. It uses **cosine similarity** as the similarity\n",
"measure to compare embeddings and build edges between them. It also allows us to specify a similarity threshold, which can be used to discard dissimilar edges from the final graph. In the following example, using 0.99 as the similarity threshold, we end up with a graph that has 111,066 bi-directional edges."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "nERXNfSWPa4Z"
},
"source": [
"**Note:** Graph quality and by extension, embedding quality, are very important\n",
"for graph regularization. While we use Swivel embeddings in this notebook, using BERT embeddings for instance, will likely capture review semantics more\n",
"accurately. We encourage users to use embeddings of their choice and as appropriate to their needs."
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:21.367290Z",
"iopub.status.busy": "2024-08-02T09:08:21.367053Z",
"iopub.status.idle": "2024-08-02T09:08:21.810621Z",
"shell.execute_reply": "2024-08-02T09:08:21.809880Z"
},
"id": "2bAttbhgPa4V"
},
"outputs": [],
"source": [
"swivel_url = 'https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1'\n",
"hub_layer = hub.KerasLayer(swivel_url, input_shape=[], dtype=tf.string)\n",
"\n",
"\n",
"def _bytes_feature(value):\n",
" \"\"\"Returns a bytes_list from a string / byte.\"\"\"\n",
" return tf.train.Feature(bytes_list=tf.train.BytesList(value=value))\n",
"\n",
"\n",
"def _float_feature(value):\n",
" \"\"\"Returns a float_list from a float / double.\"\"\"\n",
" return tf.train.Feature(float_list=tf.train.FloatList(value=value))\n",
"\n",
"\n",
"def create_embedding_example(example):\n",
" \"\"\"Create tf.Example containing the sample's embedding and its ID.\"\"\"\n",
" sentence_embedding = hub_layer(tf.sparse.to_dense(example['text']))\n",
"\n",
" # Flatten the sentence embedding back to 1-D.\n",
" sentence_embedding = tf.reshape(sentence_embedding, shape=[-1])\n",
"\n",
" feature_dict = {\n",
" 'id': _bytes_feature(tf.sparse.to_dense(example['id']).numpy()),\n",
" 'embedding': _float_feature(sentence_embedding.numpy().tolist())\n",
" }\n",
"\n",
" return tf.train.Example(features=tf.train.Features(feature=feature_dict))\n",
"\n",
"\n",
"def create_dataset(uri):\n",
" tfrecord_filenames = [os.path.join(uri, name) for name in os.listdir(uri)]\n",
" return tf.data.TFRecordDataset(tfrecord_filenames, compression_type='GZIP')\n",
"\n",
"\n",
"def create_embeddings(train_path, output_path):\n",
" dataset = create_dataset(train_path)\n",
" embeddings_path = os.path.join(output_path, 'embeddings.tfr')\n",
"\n",
" feature_map = {\n",
" 'label': tf.io.FixedLenFeature([], tf.int64),\n",
" 'id': tf.io.VarLenFeature(tf.string),\n",
" 'text': tf.io.VarLenFeature(tf.string)\n",
" }\n",
"\n",
" with tf.io.TFRecordWriter(embeddings_path) as writer:\n",
" for tfrecord in dataset:\n",
" tensor_dict = tf.io.parse_single_example(tfrecord, feature_map)\n",
" embedding_example = create_embedding_example(tensor_dict)\n",
" writer.write(embedding_example.SerializeToString())\n",
"\n",
"\n",
"def build_graph(output_path, similarity_threshold):\n",
" embeddings_path = os.path.join(output_path, 'embeddings.tfr')\n",
" graph_path = os.path.join(output_path, 'graph.tsv')\n",
" graph_builder_config = nsl.configs.GraphBuilderConfig(\n",
" similarity_threshold=similarity_threshold,\n",
" lsh_splits=32,\n",
" lsh_rounds=15,\n",
" random_seed=12345)\n",
" nsl.tools.build_graph_from_config([embeddings_path], graph_path,\n",
" graph_builder_config)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:21.814482Z",
"iopub.status.busy": "2024-08-02T09:08:21.814201Z",
"iopub.status.idle": "2024-08-02T09:08:21.820457Z",
"shell.execute_reply": "2024-08-02T09:08:21.819849Z"
},
"id": "ITkf2SLg1TG7"
},
"outputs": [],
"source": [
"\"\"\"Custom Artifact type\"\"\"\n",
"\n",
"\n",
"class SynthesizedGraph(tfx.types.artifact.Artifact):\n",
" \"\"\"Output artifact of the SynthesizeGraph component\"\"\"\n",
" TYPE_NAME = 'SynthesizedGraphPath'\n",
" PROPERTIES = {\n",
" 'span': standard_artifacts.SPAN_PROPERTY,\n",
" 'split_names': standard_artifacts.SPLIT_NAMES_PROPERTY,\n",
" }\n",
"\n",
"\n",
"@component\n",
"def SynthesizeGraph(identified_examples: InputArtifact[Examples],\n",
" synthesized_graph: OutputArtifact[SynthesizedGraph],\n",
" similarity_threshold: Parameter[float],\n",
" component_name: Parameter[str]) -> None:\n",
"\n",
" # Get a list of the splits in input_data\n",
" splits_list = artifact_utils.decode_split_names(\n",
" split_names=identified_examples.split_names)\n",
"\n",
" # We build a graph only based on the 'Split-train' split which includes both\n",
" # labeled and unlabeled examples.\n",
" train_input_examples_uri = os.path.join(identified_examples.uri,\n",
" 'Split-train')\n",
" output_graph_uri = os.path.join(synthesized_graph.uri, 'Split-train')\n",
" os.mkdir(output_graph_uri)\n",
"\n",
" print('Creating embeddings...')\n",
" create_embeddings(train_input_examples_uri, output_graph_uri)\n",
"\n",
" print('Synthesizing graph...')\n",
" build_graph(output_graph_uri, similarity_threshold)\n",
"\n",
" synthesized_graph.split_names = artifact_utils.encode_split_names(\n",
" splits=['Split-train'])\n",
"\n",
" return"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:08:21.823707Z",
"iopub.status.busy": "2024-08-02T09:08:21.823469Z",
"iopub.status.idle": "2024-08-02T09:09:59.366626Z",
"shell.execute_reply": "2024-08-02T09:09:59.365937Z"
},
"id": "H0ZkHvJMA-0G"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Creating embeddings...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Synthesizing graph...\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f1250310fd0
.execution_id | 6 |
.component | \n",
"\n",
"SynthesizeGraph at 0x7f11fc237730 .inputs | ['identified_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
| .outputs | ['synthesized_graph'] | \n",
"\n",
"Channel of type 'SynthesizedGraphPath' (1 artifact) at 0x7f11fc2375e0 .type_name | SynthesizedGraphPath | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'SynthesizedGraphPath' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6) at 0x7f11fc087d00 .type | <class '__main__.SynthesizedGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6 | .span | 0 | .split_names | ["Split-train"] |
|
|
|
| .exec_properties | ['similarity_threshold'] | 0.99 | ['component_name'] | SynthesizeGraph |
|
|
.component.inputs | ['identified_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
|
|
.component.outputs | ['synthesized_graph'] | \n",
"\n",
"Channel of type 'SynthesizedGraphPath' (1 artifact) at 0x7f11fc2375e0 .type_name | SynthesizedGraphPath | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'SynthesizedGraphPath' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6) at 0x7f11fc087d00 .type | <class '__main__.SynthesizedGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6 | .span | 0 | .split_names | ["Split-train"] |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: SynthesizeGraph\n",
" execution_id: 6\n",
" outputs:\n",
" synthesized_graph: OutputChannel(artifact_type=SynthesizedGraphPath, producer_component_id=SynthesizeGraph, output_key=synthesized_graph, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"synthesize_graph = SynthesizeGraph(\n",
" identified_examples=identify_examples.outputs['identified_examples'],\n",
" component_name=u'SynthesizeGraph',\n",
" similarity_threshold=0.99)\n",
"context.run(synthesize_graph, enable_cache=False)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:09:59.370482Z",
"iopub.status.busy": "2024-08-02T09:09:59.370197Z",
"iopub.status.idle": "2024-08-02T09:09:59.375041Z",
"shell.execute_reply": "2024-08-02T09:09:59.374484Z"
},
"id": "o54M-0Q11FcS"
},
"outputs": [
{
"data": {
"text/plain": [
"['Split-train']"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"train_uri = synthesize_graph.outputs[\"synthesized_graph\"].get()[0].uri\n",
"os.listdir(train_uri)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:09:59.378132Z",
"iopub.status.busy": "2024-08-02T09:09:59.377756Z",
"iopub.status.idle": "2024-08-02T09:09:59.698077Z",
"shell.execute_reply": "2024-08-02T09:09:59.697155Z"
},
"id": "IRK_rS_q1UcZ"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"node 1\t\t\t\t\tnode 2\t\t\t\t\tsimilarity\n",
"1e5a20fa-113d-4a4b-b901-2f51f4b74670\t0a39f83e-8d3c-4ad5-849f-38675194e720\t0.991234\r\n",
"0a39f83e-8d3c-4ad5-849f-38675194e720\t1e5a20fa-113d-4a4b-b901-2f51f4b74670\t0.991234\r\n",
"0a39f83e-8d3c-4ad5-849f-38675194e720\t771c9b5c-07a4-491f-a515-bb10a11a8705\t0.990838\r\n",
"771c9b5c-07a4-491f-a515-bb10a11a8705\t0a39f83e-8d3c-4ad5-849f-38675194e720\t0.990838\r\n",
"030d35c0-0db9-4f28-8707-cfa8c5f483d3\t771c9b5c-07a4-491f-a515-bb10a11a8705\t0.990184\r\n",
"771c9b5c-07a4-491f-a515-bb10a11a8705\t030d35c0-0db9-4f28-8707-cfa8c5f483d3\t0.990184\r\n",
"55763705-7e7a-4a39-9a65-c61f06871924\t095d197d-3cf3-40df-a4b0-1ebdd6ace9a5\t0.992823\r\n",
"095d197d-3cf3-40df-a4b0-1ebdd6ace9a5\t55763705-7e7a-4a39-9a65-c61f06871924\t0.992823\r\n",
"c471129f-08ff-4eb7-887f-7c8e47b6c224\t465070dd-60cf-4a54-8171-369bc1c68637\t0.990020\r\n",
"465070dd-60cf-4a54-8171-369bc1c68637\tc471129f-08ff-4eb7-887f-7c8e47b6c224\t0.990020\r\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"...\n",
"c5c4b0cd-b721-4993-9840-0831d3fdb5f0\t7c8b2f1c-2e23-43ad-acab-4acf280e007b\t0.991327\r\n",
"7c8b2f1c-2e23-43ad-acab-4acf280e007b\tc5c4b0cd-b721-4993-9840-0831d3fdb5f0\t0.991327\r\n",
"202e428e-c62b-4202-a2a4-eeb0eccf6cee\td5dfaadb-7e66-41cf-9b30-fa594b63534c\t0.991046\r\n",
"d5dfaadb-7e66-41cf-9b30-fa594b63534c\t202e428e-c62b-4202-a2a4-eeb0eccf6cee\t0.991046\r\n",
"58c91cb8-59ef-421f-b014-eff6e66c5214\t564daa6f-1f36-46a0-87cc-56b0a6c7bd4c\t0.991198\r\n",
"564daa6f-1f36-46a0-87cc-56b0a6c7bd4c\t58c91cb8-59ef-421f-b014-eff6e66c5214\t0.991198\r\n",
"007922e8-2a03-4ba9-9e9c-af99f22303b2\te6319e60-e3c8-4d1b-b269-97dc552d8a15\t0.990260\r\n",
"e6319e60-e3c8-4d1b-b269-97dc552d8a15\t007922e8-2a03-4ba9-9e9c-af99f22303b2\t0.990260\r\n",
"3e42725a-bd42-4fba-91d1-eb6fd6e70a8b\tee568e35-a727-489e-b458-e4b7cce70a81\t0.991317\r\n",
"ee568e35-a727-489e-b458-e4b7cce70a81\t3e42725a-bd42-4fba-91d1-eb6fd6e70a8b\t0.991317\r\n"
]
}
],
"source": [
"graph_path = os.path.join(train_uri, \"Split-train\", \"graph.tsv\")\n",
"print(\"node 1\\t\\t\\t\\t\\tnode 2\\t\\t\\t\\t\\tsimilarity\")\n",
"!head {graph_path}\n",
"print(\"...\")\n",
"!tail {graph_path}"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:09:59.701978Z",
"iopub.status.busy": "2024-08-02T09:09:59.701693Z",
"iopub.status.idle": "2024-08-02T09:09:59.865689Z",
"shell.execute_reply": "2024-08-02T09:09:59.864795Z"
},
"id": "uybqyWztvCGm"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"222132 /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6/Split-train/graph.tsv\r\n"
]
}
],
"source": [
"!wc -l {graph_path}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "JPViEz5RlA36"
},
"source": [
"### The Transform Component\n",
"\n",
"The `Transform` component performs data transformations and feature engineering. The results include an input TensorFlow graph which is used during both training and serving to preprocess the data before training or inference. This graph becomes part of the SavedModel that is the result of model training. Since the same input graph is used for both training and serving, the preprocessing will always be the same, and only needs to be written once.\n",
"\n",
"The Transform component requires more code than many other components because of the arbitrary complexity of the feature engineering that you may need for the data and/or model that you're working with. It requires code files to be available which define the processing needed."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "_USkfut69gNW"
},
"source": [
"Each sample will include the following three features:\n",
"\n",
"1. **id**: The node ID of the sample.\n",
"2. **text_xf**: An int64 list containing word IDs.\n",
"3. **label_xf**: A singleton int64 identifying the target class of the review: 0=negative, 1=positive."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "XUYeCayFG7kH"
},
"source": [
"Let's define a module containing the `preprocessing_fn()` function that we will pass to the `Transform` component:"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:09:59.869994Z",
"iopub.status.busy": "2024-08-02T09:09:59.869707Z",
"iopub.status.idle": "2024-08-02T09:09:59.873650Z",
"shell.execute_reply": "2024-08-02T09:09:59.873027Z"
},
"id": "7uuWiQbOG9ki"
},
"outputs": [],
"source": [
"_transform_module_file = 'imdb_transform.py'"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:09:59.876753Z",
"iopub.status.busy": "2024-08-02T09:09:59.876524Z",
"iopub.status.idle": "2024-08-02T09:09:59.882914Z",
"shell.execute_reply": "2024-08-02T09:09:59.882334Z"
},
"id": "v3EIuVQnBfH7"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing imdb_transform.py\n"
]
}
],
"source": [
"%%writefile {_transform_module_file}\n",
"\n",
"import tensorflow as tf\n",
"\n",
"import tensorflow_transform as tft\n",
"\n",
"SEQUENCE_LENGTH = 100\n",
"VOCAB_SIZE = 10000\n",
"OOV_SIZE = 100\n",
"\n",
"def tokenize_reviews(reviews, sequence_length=SEQUENCE_LENGTH):\n",
" reviews = tf.strings.lower(reviews)\n",
" reviews = tf.strings.regex_replace(reviews, r\" '| '|^'|'$\", \" \")\n",
" reviews = tf.strings.regex_replace(reviews, \"[^a-z' ]\", \" \")\n",
" tokens = tf.strings.split(reviews)[:, :sequence_length]\n",
" start_tokens = tf.fill([tf.shape(reviews)[0], 1], \"\")\n",
" end_tokens = tf.fill([tf.shape(reviews)[0], 1], \"\")\n",
" tokens = tf.concat([start_tokens, tokens, end_tokens], axis=1)\n",
" tokens = tokens[:, :sequence_length]\n",
" tokens = tokens.to_tensor(default_value=\"\")\n",
" pad = sequence_length - tf.shape(tokens)[1]\n",
" tokens = tf.pad(tokens, [[0, 0], [0, pad]], constant_values=\"\")\n",
" return tf.reshape(tokens, [-1, sequence_length])\n",
"\n",
"def preprocessing_fn(inputs):\n",
" \"\"\"tf.transform's callback function for preprocessing inputs.\n",
"\n",
" Args:\n",
" inputs: map from feature keys to raw not-yet-transformed features.\n",
"\n",
" Returns:\n",
" Map from string feature key to transformed feature operations.\n",
" \"\"\"\n",
" outputs = {}\n",
" outputs[\"id\"] = inputs[\"id\"]\n",
" tokens = tokenize_reviews(_fill_in_missing(inputs[\"text\"], ''))\n",
" outputs[\"text_xf\"] = tft.compute_and_apply_vocabulary(\n",
" tokens,\n",
" top_k=VOCAB_SIZE,\n",
" num_oov_buckets=OOV_SIZE)\n",
" outputs[\"label_xf\"] = _fill_in_missing(inputs[\"label\"], -1)\n",
" return outputs\n",
"\n",
"def _fill_in_missing(x, default_value):\n",
" \"\"\"Replace missing values in a SparseTensor.\n",
"\n",
" Fills in missing values of `x` with the default_value.\n",
"\n",
" Args:\n",
" x: A `SparseTensor` of rank 2. Its dense shape should have size at most 1\n",
" in the second dimension.\n",
" default_value: the value with which to replace the missing values.\n",
"\n",
" Returns:\n",
" A rank 1 tensor where missing values of `x` have been filled in.\n",
" \"\"\"\n",
" if not isinstance(x, tf.sparse.SparseTensor):\n",
" return x\n",
" return tf.squeeze(\n",
" tf.sparse.to_dense(\n",
" tf.SparseTensor(x.indices, x.values, [x.dense_shape[0], 1]),\n",
" default_value),\n",
" axis=1)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eeMVMafpHHX1"
},
"source": [
"Create and run the `Transform` component, referring to the files that were created above."
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:09:59.885971Z",
"iopub.status.busy": "2024-08-02T09:09:59.885724Z",
"iopub.status.idle": "2024-08-02T09:10:31.214039Z",
"shell.execute_reply": "2024-08-02T09:10:31.213276Z"
},
"id": "jHfhth_GiZI9"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"running bdist_wheel\n",
"running build\n",
"running build_py\n",
"creating build\n",
"creating build/lib\n",
"copying imdb_transform.py -> build/lib\n",
"installing to /tmpfs/tmp/tmpekjtp2ps\n",
"running install\n",
"running install_lib\n",
"copying build/lib/imdb_transform.py -> /tmpfs/tmp/tmpekjtp2ps\n",
"running install_egg_info\n",
"running egg_info\n",
"creating tfx_user_code_Transform.egg-info\n",
"writing tfx_user_code_Transform.egg-info/PKG-INFO\n",
"writing dependency_links to tfx_user_code_Transform.egg-info/dependency_links.txt\n",
"writing top-level names to tfx_user_code_Transform.egg-info/top_level.txt\n",
"writing manifest file 'tfx_user_code_Transform.egg-info/SOURCES.txt'\n",
"reading manifest file 'tfx_user_code_Transform.egg-info/SOURCES.txt'\n",
"writing manifest file 'tfx_user_code_Transform.egg-info/SOURCES.txt'\n",
"Copying tfx_user_code_Transform.egg-info to /tmpfs/tmp/tmpekjtp2ps/tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50-py3.9.egg-info\n",
"running install_scripts\n",
"creating /tmpfs/tmp/tmpekjtp2ps/tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50.dist-info/WHEEL\n",
"creating '/tmpfs/tmp/tmpzx67rser/tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50-py3-none-any.whl' and adding '/tmpfs/tmp/tmpekjtp2ps' to it\n",
"adding 'imdb_transform.py'\n",
"adding 'tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50.dist-info/METADATA'\n",
"adding 'tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50.dist-info/WHEEL'\n",
"adding 'tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50.dist-info/top_level.txt'\n",
"adding 'tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50.dist-info/RECORD'\n",
"removing /tmpfs/tmp/tmpekjtp2ps\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmpfs/src/tf_docs_env/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.\n",
"!!\n",
"\n",
" ********************************************************************************\n",
" Please avoid running ``setup.py`` directly.\n",
" Instead, use pypa/build, pypa/installer or other\n",
" standards-based tools.\n",
"\n",
" See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.\n",
" ********************************************************************************\n",
"\n",
"!!\n",
" self.initialize_options()\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/_wheels/tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50-py3-none-any.whl\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Installing collected packages: tfx-user-code-Transform\n",
"Successfully installed tfx-user-code-Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/_wheels/tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50-py3-none-any.whl\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Installing collected packages: tfx-user-code-Transform\n",
"Successfully installed tfx-user-code-Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/_wheels/tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50-py3-none-any.whl\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Installing collected packages: tfx-user-code-Transform\n",
"Successfully installed tfx-user-code-Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:Tables initialized inside a tf.function will be re-initialized on every invocation of the function. This re-initialization can have significant impact on performance. Consider lifting them out of the graph context using `tf.init_scope`.: compute_and_apply_vocabulary/apply_vocab/text_file_init/InitializeTableFromTextFileV2\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:Tables initialized inside a tf.function will be re-initialized on every invocation of the function. This re-initialization can have significant impact on performance. Consider lifting them out of the graph context using `tf.init_scope`.: compute_and_apply_vocabulary/apply_vocab/text_file_init/InitializeTableFromTextFileV2\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7/.temp_path/tftransform_tmp/394d576f22a342099b3a96428fe005f1/assets\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7/.temp_path/tftransform_tmp/394d576f22a342099b3a96428fe005f1/assets\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7/.temp_path/tftransform_tmp/1d81f1db01d34c12bd9832f63dede4e7/assets\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7/.temp_path/tftransform_tmp/1d81f1db01d34c12bd9832f63dede4e7/assets\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f11d0451a60
.execution_id | 7 |
.component | \n",
"\n",
"Transform at 0x7f11fc237430 .inputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
| ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
| .outputs | ['transform_graph'] | \n",
"\n",
"Channel of type 'TransformGraph' (1 artifact) at 0x7f11fc207160 .type_name | TransformGraph | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'TransformGraph' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7) at 0x7f11fc207370 .type | <class 'tfx.types.standard_artifacts.TransformGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7 |
|
|
| ['transformed_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f11fc207c10 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7) at 0x7f11fc207430 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
| ['updated_analyzer_cache'] | \n",
"\n",
"Channel of type 'TransformCache' (1 artifact) at 0x7f11fc207bb0 .type_name | TransformCache | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'TransformCache' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/updated_analyzer_cache/7) at 0x7f11fc207fa0 .type | <class 'tfx.types.standard_artifacts.TransformCache'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/updated_analyzer_cache/7 |
|
|
| ['pre_transform_schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc207d00 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_schema/7) at 0x7f11fc208d00 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_schema/7 |
|
|
| ['pre_transform_stats'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f11fc2072e0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_stats/7) at 0x7f11fc208730 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_stats/7 | .span | 0 | .split_names | |
|
|
| ['post_transform_schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc207400 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_schema/7) at 0x7f11fc2080d0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_schema/7 |
|
|
| ['post_transform_stats'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f11fc207a90 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_stats/7) at 0x7f11fc208df0 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_stats/7 | .span | 0 | .split_names | |
|
|
| ['post_transform_anomalies'] | \n",
"\n",
"Channel of type 'ExampleAnomalies' (1 artifact) at 0x7f11fc2072b0 .type_name | ExampleAnomalies | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleAnomalies' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_anomalies/7) at 0x7f11fc208820 .type | <class 'tfx.types.standard_artifacts.ExampleAnomalies'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_anomalies/7 | .span | 0 | .split_names | |
|
|
|
| .exec_properties | ['module_file'] | None | ['preprocessing_fn'] | None | ['stats_options_updater_fn'] | None | ['force_tf_compat_v1'] | 0 | ['custom_config'] | null | ['splits_config'] | None | ['disable_statistics'] | 0 | ['module_path'] | imdb_transform@/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/_wheels/tfx_user_code_Transform-0.0+074f608d1f54105225e2fee77ebe4b6159a009eca01b5a0791099840a2185d50-py3-none-any.whl |
|
|
.component.inputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f12202ee100 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2) at 0x7f139f57ea00 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/IdentifyExamples/identified_examples/2 | .span | 0 | .split_names | ["train", "eval"] | .version | 0 |
|
|
| ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
|
.component.outputs | ['transform_graph'] | \n",
"\n",
"Channel of type 'TransformGraph' (1 artifact) at 0x7f11fc207160 .type_name | TransformGraph | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'TransformGraph' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7) at 0x7f11fc207370 .type | <class 'tfx.types.standard_artifacts.TransformGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7 |
|
|
| ['transformed_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f11fc207c10 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7) at 0x7f11fc207430 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
| ['updated_analyzer_cache'] | \n",
"\n",
"Channel of type 'TransformCache' (1 artifact) at 0x7f11fc207bb0 .type_name | TransformCache | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'TransformCache' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/updated_analyzer_cache/7) at 0x7f11fc207fa0 .type | <class 'tfx.types.standard_artifacts.TransformCache'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/updated_analyzer_cache/7 |
|
|
| ['pre_transform_schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc207d00 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_schema/7) at 0x7f11fc208d00 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_schema/7 |
|
|
| ['pre_transform_stats'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f11fc2072e0 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_stats/7) at 0x7f11fc208730 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/pre_transform_stats/7 | .span | 0 | .split_names | |
|
|
| ['post_transform_schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc207400 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_schema/7) at 0x7f11fc2080d0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_schema/7 |
|
|
| ['post_transform_stats'] | \n",
"\n",
"Channel of type 'ExampleStatistics' (1 artifact) at 0x7f11fc207a90 .type_name | ExampleStatistics | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleStatistics' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_stats/7) at 0x7f11fc208df0 .type | <class 'tfx.types.standard_artifacts.ExampleStatistics'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_stats/7 | .span | 0 | .split_names | |
|
|
| ['post_transform_anomalies'] | \n",
"\n",
"Channel of type 'ExampleAnomalies' (1 artifact) at 0x7f11fc2072b0 .type_name | ExampleAnomalies | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ExampleAnomalies' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_anomalies/7) at 0x7f11fc208820 .type | <class 'tfx.types.standard_artifacts.ExampleAnomalies'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/post_transform_anomalies/7 | .span | 0 | .split_names | |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: Transform\n",
" execution_id: 7\n",
" outputs:\n",
" transform_graph: OutputChannel(artifact_type=TransformGraph, producer_component_id=Transform, output_key=transform_graph, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" transformed_examples: OutputChannel(artifact_type=Examples, producer_component_id=Transform, output_key=transformed_examples, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" updated_analyzer_cache: OutputChannel(artifact_type=TransformCache, producer_component_id=Transform, output_key=updated_analyzer_cache, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" pre_transform_schema: OutputChannel(artifact_type=Schema, producer_component_id=Transform, output_key=pre_transform_schema, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" pre_transform_stats: OutputChannel(artifact_type=ExampleStatistics, producer_component_id=Transform, output_key=pre_transform_stats, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" post_transform_schema: OutputChannel(artifact_type=Schema, producer_component_id=Transform, output_key=post_transform_schema, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" post_transform_stats: OutputChannel(artifact_type=ExampleStatistics, producer_component_id=Transform, output_key=post_transform_stats, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" post_transform_anomalies: OutputChannel(artifact_type=ExampleAnomalies, producer_component_id=Transform, output_key=post_transform_anomalies, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Performs transformations and feature engineering in training and serving.\n",
"transform = Transform(\n",
" examples=identify_examples.outputs['identified_examples'],\n",
" schema=schema_gen.outputs['schema'],\n",
" module_file=_transform_module_file)\n",
"context.run(transform, enable_cache=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "_jbZO1ykHOeG"
},
"source": [
"The `Transform` component has 2 types of outputs:\n",
"* `transform_graph` is the graph that can perform the preprocessing operations (this graph will be included in the serving and evaluation models).\n",
"* `transformed_examples` represents the preprocessed training and evaluation data."
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:31.219478Z",
"iopub.status.busy": "2024-08-02T09:10:31.219156Z",
"iopub.status.idle": "2024-08-02T09:10:31.224015Z",
"shell.execute_reply": "2024-08-02T09:10:31.223362Z"
},
"id": "j4UjersvAC7p"
},
"outputs": [
{
"data": {
"text/plain": [
"{'transform_graph': OutputChannel(artifact_type=TransformGraph, producer_component_id=Transform, output_key=transform_graph, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False),\n",
" 'transformed_examples': OutputChannel(artifact_type=Examples, producer_component_id=Transform, output_key=transformed_examples, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False),\n",
" 'updated_analyzer_cache': OutputChannel(artifact_type=TransformCache, producer_component_id=Transform, output_key=updated_analyzer_cache, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False),\n",
" 'pre_transform_schema': OutputChannel(artifact_type=Schema, producer_component_id=Transform, output_key=pre_transform_schema, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False),\n",
" 'pre_transform_stats': OutputChannel(artifact_type=ExampleStatistics, producer_component_id=Transform, output_key=pre_transform_stats, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False),\n",
" 'post_transform_schema': OutputChannel(artifact_type=Schema, producer_component_id=Transform, output_key=post_transform_schema, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False),\n",
" 'post_transform_stats': OutputChannel(artifact_type=ExampleStatistics, producer_component_id=Transform, output_key=post_transform_stats, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False),\n",
" 'post_transform_anomalies': OutputChannel(artifact_type=ExampleAnomalies, producer_component_id=Transform, output_key=post_transform_anomalies, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)}"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"transform.outputs"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wRFMlRcdHlQy"
},
"source": [
"Take a peek at the `transform_graph` artifact: it points to a directory containing 3 subdirectories:"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:31.227264Z",
"iopub.status.busy": "2024-08-02T09:10:31.226712Z",
"iopub.status.idle": "2024-08-02T09:10:31.231235Z",
"shell.execute_reply": "2024-08-02T09:10:31.230661Z"
},
"id": "E4I-cqfQQvaW"
},
"outputs": [
{
"data": {
"text/plain": [
"['metadata', 'transformed_metadata', 'transform_fn']"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"train_uri = transform.outputs['transform_graph'].get()[0].uri\n",
"os.listdir(train_uri)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9374B4RpHzor"
},
"source": [
"The `transform_fn` subdirectory contains the actual preprocessing graph. The `metadata` subdirectory contains the schema of the original data. The `transformed_metadata` subdirectory contains the schema of the preprocessed data.\n",
"\n",
"Take a look at some of the transformed examples and check that they are indeed processed as intended."
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:31.234873Z",
"iopub.status.busy": "2024-08-02T09:10:31.234314Z",
"iopub.status.idle": "2024-08-02T09:10:31.239169Z",
"shell.execute_reply": "2024-08-02T09:10:31.238584Z"
},
"id": "-QPONyzDTswf"
},
"outputs": [],
"source": [
"def pprint_examples(artifact, n_examples=3):\n",
" print(\"artifact:\", artifact)\n",
" uri = os.path.join(artifact.uri, \"Split-train\")\n",
" print(\"uri:\", uri)\n",
" tfrecord_filenames = [os.path.join(uri, name) for name in os.listdir(uri)]\n",
" print(\"tfrecord_filenames:\", tfrecord_filenames)\n",
" dataset = tf.data.TFRecordDataset(tfrecord_filenames, compression_type=\"GZIP\")\n",
" for tfrecord in dataset.take(n_examples):\n",
" serialized_example = tfrecord.numpy()\n",
" example = tf.train.Example.FromString(serialized_example)\n",
" pp.pprint(example)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:31.242440Z",
"iopub.status.busy": "2024-08-02T09:10:31.241962Z",
"iopub.status.idle": "2024-08-02T09:10:31.280398Z",
"shell.execute_reply": "2024-08-02T09:10:31.279729Z"
},
"id": "2zIepQhSQoPa"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"artifact: Artifact(artifact: id: 8\n",
"type_id: 14\n",
"uri: \"/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7\"\n",
"properties {\n",
" key: \"split_names\"\n",
" value {\n",
" string_value: \"[\\\"eval\\\", \\\"train\\\"]\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"name\"\n",
" value {\n",
" string_value: \"transformed_examples:2024-08-02T09:09:59.887990\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"producer_component\"\n",
" value {\n",
" string_value: \"Transform\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"tfx_version\"\n",
" value {\n",
" string_value: \"1.15.1\"\n",
" }\n",
"}\n",
"state: LIVE\n",
"name: \"transformed_examples:2024-08-02T09:09:59.887990\"\n",
", artifact_type: id: 14\n",
"name: \"Examples\"\n",
"properties {\n",
" key: \"span\"\n",
" value: INT\n",
"}\n",
"properties {\n",
" key: \"split_names\"\n",
" value: STRING\n",
"}\n",
"properties {\n",
" key: \"version\"\n",
" value: INT\n",
"}\n",
"base_type: DATASET\n",
")\n",
"uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7/Split-train\n",
"tfrecord_filenames: ['/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7/Split-train/transformed_examples-00000-of-00001.gz']\n",
"features {\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"d7a8912a-cea4-4453-a79e-fbbe5785e9ee\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 8\n",
" value: 14\n",
" value: 32\n",
" value: 338\n",
" value: 310\n",
" value: 15\n",
" value: 95\n",
" value: 27\n",
" value: 10001\n",
" value: 9\n",
" value: 31\n",
" value: 1173\n",
" value: 3153\n",
" value: 43\n",
" value: 495\n",
" value: 10060\n",
" value: 214\n",
" value: 26\n",
" value: 71\n",
" value: 142\n",
" value: 19\n",
" value: 8\n",
" value: 204\n",
" value: 339\n",
" value: 27\n",
" value: 74\n",
" value: 181\n",
" value: 238\n",
" value: 9\n",
" value: 440\n",
" value: 67\n",
" value: 74\n",
" value: 71\n",
" value: 94\n",
" value: 100\n",
" value: 22\n",
" value: 5442\n",
" value: 8\n",
" value: 1573\n",
" value: 607\n",
" value: 530\n",
" value: 8\n",
" value: 15\n",
" value: 6\n",
" value: 32\n",
" value: 378\n",
" value: 6292\n",
" value: 207\n",
" value: 2276\n",
" value: 388\n",
" value: 0\n",
" value: 84\n",
" value: 1023\n",
" value: 154\n",
" value: 65\n",
" value: 155\n",
" value: 52\n",
" value: 0\n",
" value: 10080\n",
" value: 7871\n",
" value: 65\n",
" value: 250\n",
" value: 74\n",
" value: 3202\n",
" value: 20\n",
" value: 10000\n",
" value: 3720\n",
" value: 10020\n",
" value: 10008\n",
" value: 1282\n",
" value: 3862\n",
" value: 3\n",
" value: 53\n",
" value: 3952\n",
" value: 110\n",
" value: 1879\n",
" value: 17\n",
" value: 3153\n",
" value: 14\n",
" value: 166\n",
" value: 19\n",
" value: 2\n",
" value: 1023\n",
" value: 1007\n",
" value: 9405\n",
" value: 9\n",
" value: 2\n",
" value: 15\n",
" value: 12\n",
" value: 14\n",
" value: 4504\n",
" value: 4\n",
" value: 109\n",
" value: 158\n",
" value: 1202\n",
" value: 7\n",
" value: 174\n",
" value: 505\n",
" value: 12\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"features {\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"ed97ab48-01a6-46f7-81d7-2bf3f448ff22\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 7\n",
" value: 23\n",
" value: 75\n",
" value: 494\n",
" value: 5\n",
" value: 748\n",
" value: 2155\n",
" value: 307\n",
" value: 91\n",
" value: 19\n",
" value: 8\n",
" value: 6\n",
" value: 499\n",
" value: 763\n",
" value: 5\n",
" value: 2\n",
" value: 1690\n",
" value: 4\n",
" value: 200\n",
" value: 593\n",
" value: 57\n",
" value: 1244\n",
" value: 120\n",
" value: 2364\n",
" value: 3\n",
" value: 4407\n",
" value: 21\n",
" value: 0\n",
" value: 10081\n",
" value: 3\n",
" value: 263\n",
" value: 42\n",
" value: 6947\n",
" value: 2\n",
" value: 169\n",
" value: 185\n",
" value: 21\n",
" value: 8\n",
" value: 5143\n",
" value: 7\n",
" value: 1339\n",
" value: 2155\n",
" value: 81\n",
" value: 0\n",
" value: 18\n",
" value: 14\n",
" value: 1468\n",
" value: 0\n",
" value: 86\n",
" value: 986\n",
" value: 14\n",
" value: 2259\n",
" value: 1790\n",
" value: 562\n",
" value: 3\n",
" value: 284\n",
" value: 200\n",
" value: 401\n",
" value: 5\n",
" value: 668\n",
" value: 19\n",
" value: 17\n",
" value: 58\n",
" value: 1934\n",
" value: 4\n",
" value: 45\n",
" value: 14\n",
" value: 4212\n",
" value: 113\n",
" value: 43\n",
" value: 135\n",
" value: 7\n",
" value: 753\n",
" value: 7\n",
" value: 224\n",
" value: 23\n",
" value: 1155\n",
" value: 179\n",
" value: 4\n",
" value: 0\n",
" value: 18\n",
" value: 19\n",
" value: 7\n",
" value: 191\n",
" value: 0\n",
" value: 2047\n",
" value: 4\n",
" value: 10\n",
" value: 3\n",
" value: 283\n",
" value: 42\n",
" value: 401\n",
" value: 5\n",
" value: 668\n",
" value: 4\n",
" value: 90\n",
" value: 234\n",
" value: 10023\n",
" value: 227\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"features {\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"8fe0aa92-b194-4ed1-98e7-3f72be67ea75\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 4577\n",
" value: 7158\n",
" value: 0\n",
" value: 10047\n",
" value: 3778\n",
" value: 3346\n",
" value: 9\n",
" value: 2\n",
" value: 758\n",
" value: 1915\n",
" value: 3\n",
" value: 2280\n",
" value: 1511\n",
" value: 3\n",
" value: 2003\n",
" value: 10020\n",
" value: 225\n",
" value: 786\n",
" value: 382\n",
" value: 16\n",
" value: 39\n",
" value: 203\n",
" value: 361\n",
" value: 5\n",
" value: 93\n",
" value: 11\n",
" value: 11\n",
" value: 19\n",
" value: 220\n",
" value: 21\n",
" value: 341\n",
" value: 2\n",
" value: 10000\n",
" value: 966\n",
" value: 0\n",
" value: 77\n",
" value: 4\n",
" value: 6677\n",
" value: 464\n",
" value: 10071\n",
" value: 5\n",
" value: 10042\n",
" value: 630\n",
" value: 2\n",
" value: 10044\n",
" value: 404\n",
" value: 2\n",
" value: 10044\n",
" value: 3\n",
" value: 5\n",
" value: 10008\n",
" value: 0\n",
" value: 1259\n",
" value: 630\n",
" value: 106\n",
" value: 10042\n",
" value: 6721\n",
" value: 10\n",
" value: 49\n",
" value: 21\n",
" value: 0\n",
" value: 2071\n",
" value: 20\n",
" value: 1292\n",
" value: 4\n",
" value: 0\n",
" value: 431\n",
" value: 11\n",
" value: 11\n",
" value: 166\n",
" value: 67\n",
" value: 2342\n",
" value: 5815\n",
" value: 12\n",
" value: 575\n",
" value: 21\n",
" value: 0\n",
" value: 1691\n",
" value: 537\n",
" value: 4\n",
" value: 0\n",
" value: 3605\n",
" value: 307\n",
" value: 0\n",
" value: 10054\n",
" value: 1563\n",
" value: 3115\n",
" value: 467\n",
" value: 4577\n",
" value: 3\n",
" value: 1069\n",
" value: 1158\n",
" value: 5\n",
" value: 23\n",
" value: 4279\n",
" value: 6677\n",
" value: 464\n",
" value: 20\n",
" value: 10004\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n"
]
}
],
"source": [
"pprint_examples(transform.outputs['transformed_examples'].get()[0])"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "vpGvPKielIvI"
},
"source": [
"### The GraphAugmentation Component\n",
"\n",
"Since we have the sample features and the synthesized graph, we can generate the\n",
"augmented training data for Neural Structured Learning. The NSL framework\n",
"provides a library to combine the graph and the sample features to produce\n",
"the final training data for graph regularization. The resulting training data\n",
"will include original sample features as well as features of their corresponding\n",
"neighbors.\n",
"\n",
"In this tutorial, we consider undirected edges and use a maximum of 3 neighbors\n",
"per sample to augment training data with graph neighbors."
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:31.283923Z",
"iopub.status.busy": "2024-08-02T09:10:31.283235Z",
"iopub.status.idle": "2024-08-02T09:10:31.296503Z",
"shell.execute_reply": "2024-08-02T09:10:31.295836Z"
},
"id": "gI6P_-AXGm04"
},
"outputs": [],
"source": [
"def split_train_and_unsup(input_uri):\n",
" 'Separate the labeled and unlabeled instances.'\n",
"\n",
" tmp_dir = tempfile.mkdtemp(prefix='tfx-data')\n",
" tfrecord_filenames = [\n",
" os.path.join(input_uri, filename) for filename in os.listdir(input_uri)\n",
" ]\n",
" train_path = os.path.join(tmp_dir, 'train.tfrecord')\n",
" unsup_path = os.path.join(tmp_dir, 'unsup.tfrecord')\n",
" with tf.io.TFRecordWriter(train_path) as train_writer, \\\n",
" tf.io.TFRecordWriter(unsup_path) as unsup_writer:\n",
" for tfrecord in tf.data.TFRecordDataset(\n",
" tfrecord_filenames, compression_type='GZIP'):\n",
" example = tf.train.Example()\n",
" example.ParseFromString(tfrecord.numpy())\n",
" if ('label_xf' not in example.features.feature or\n",
" example.features.feature['label_xf'].int64_list.value[0] == -1):\n",
" writer = unsup_writer\n",
" else:\n",
" writer = train_writer\n",
" writer.write(tfrecord.numpy())\n",
" return train_path, unsup_path\n",
"\n",
"\n",
"def gzip(filepath):\n",
" with open(filepath, 'rb') as f_in:\n",
" with gzip_lib.open(filepath + '.gz', 'wb') as f_out:\n",
" shutil.copyfileobj(f_in, f_out)\n",
" os.remove(filepath)\n",
"\n",
"\n",
"def copy_tfrecords(input_uri, output_uri):\n",
" for filename in os.listdir(input_uri):\n",
" input_filename = os.path.join(input_uri, filename)\n",
" output_filename = os.path.join(output_uri, filename)\n",
" shutil.copyfile(input_filename, output_filename)\n",
"\n",
"\n",
"@component\n",
"def GraphAugmentation(identified_examples: InputArtifact[Examples],\n",
" synthesized_graph: InputArtifact[SynthesizedGraph],\n",
" augmented_examples: OutputArtifact[Examples],\n",
" num_neighbors: Parameter[int],\n",
" component_name: Parameter[str]) -> None:\n",
"\n",
" # Get a list of the splits in input_data\n",
" splits_list = artifact_utils.decode_split_names(\n",
" split_names=identified_examples.split_names)\n",
"\n",
" train_input_uri = os.path.join(identified_examples.uri, 'Split-train')\n",
" eval_input_uri = os.path.join(identified_examples.uri, 'Split-eval')\n",
" train_graph_uri = os.path.join(synthesized_graph.uri, 'Split-train')\n",
" train_output_uri = os.path.join(augmented_examples.uri, 'Split-train')\n",
" eval_output_uri = os.path.join(augmented_examples.uri, 'Split-eval')\n",
"\n",
" os.mkdir(train_output_uri)\n",
" os.mkdir(eval_output_uri)\n",
"\n",
" # Separate the labeled and unlabeled examples from the 'Split-train' split.\n",
" train_path, unsup_path = split_train_and_unsup(train_input_uri)\n",
"\n",
" output_path = os.path.join(train_output_uri, 'nsl_train_data.tfr')\n",
" pack_nbrs_args = dict(\n",
" labeled_examples_path=train_path,\n",
" unlabeled_examples_path=unsup_path,\n",
" graph_path=os.path.join(train_graph_uri, 'graph.tsv'),\n",
" output_training_data_path=output_path,\n",
" add_undirected_edges=True,\n",
" max_nbrs=num_neighbors)\n",
" print('nsl.tools.pack_nbrs arguments:', pack_nbrs_args)\n",
" nsl.tools.pack_nbrs(**pack_nbrs_args)\n",
"\n",
" # Downstream components expect gzip'ed TFRecords.\n",
" gzip(output_path)\n",
"\n",
" # The test examples are left untouched and are simply copied over.\n",
" copy_tfrecords(eval_input_uri, eval_output_uri)\n",
"\n",
" augmented_examples.split_names = identified_examples.split_names\n",
"\n",
" return"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:31.299431Z",
"iopub.status.busy": "2024-08-02T09:10:31.299127Z",
"iopub.status.idle": "2024-08-02T09:10:39.264194Z",
"shell.execute_reply": "2024-08-02T09:10:39.263372Z"
},
"id": "r9MIEVDiOANe"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"nsl.tools.pack_nbrs arguments: {'labeled_examples_path': '/tmpfs/tmp/tfx-dataetf_kj51/train.tfrecord', 'unlabeled_examples_path': '/tmpfs/tmp/tfx-dataetf_kj51/unsup.tfrecord', 'graph_path': '/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6/Split-train/graph.tsv', 'output_training_data_path': '/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8/Split-train/nsl_train_data.tfr', 'add_undirected_edges': True, 'max_nbrs': 3}\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f1210112130
.execution_id | 8 |
.component | \n",
"\n",
"GraphAugmentation at 0x7f139160c8b0 .inputs | ['identified_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f11fc207c10 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7) at 0x7f11fc207430 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
| ['synthesized_graph'] | \n",
"\n",
"Channel of type 'SynthesizedGraphPath' (1 artifact) at 0x7f11fc2375e0 .type_name | SynthesizedGraphPath | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'SynthesizedGraphPath' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6) at 0x7f11fc087d00 .type | <class '__main__.SynthesizedGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6 | .span | 0 | .split_names | ["Split-train"] |
|
|
|
| .outputs | ['augmented_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f139160c580 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8) at 0x7f11a05f14c0 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
|
| .exec_properties | ['num_neighbors'] | 3 | ['component_name'] | GraphAugmentation |
|
|
.component.inputs | ['identified_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f11fc207c10 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7) at 0x7f11fc207430 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transformed_examples/7 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
| ['synthesized_graph'] | \n",
"\n",
"Channel of type 'SynthesizedGraphPath' (1 artifact) at 0x7f11fc2375e0 .type_name | SynthesizedGraphPath | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'SynthesizedGraphPath' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6) at 0x7f11fc087d00 .type | <class '__main__.SynthesizedGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SynthesizeGraph/synthesized_graph/6 | .span | 0 | .split_names | ["Split-train"] |
|
|
|
|
.component.outputs | ['augmented_examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f139160c580 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8) at 0x7f11a05f14c0 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: GraphAugmentation\n",
" execution_id: 8\n",
" outputs:\n",
" augmented_examples: OutputChannel(artifact_type=Examples, producer_component_id=GraphAugmentation, output_key=augmented_examples, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Augments training data with graph neighbors.\n",
"graph_augmentation = GraphAugmentation(\n",
" identified_examples=transform.outputs['transformed_examples'],\n",
" synthesized_graph=synthesize_graph.outputs['synthesized_graph'],\n",
" component_name=u'GraphAugmentation',\n",
" num_neighbors=3)\n",
"context.run(graph_augmentation, enable_cache=False)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:39.267952Z",
"iopub.status.busy": "2024-08-02T09:10:39.267663Z",
"iopub.status.idle": "2024-08-02T09:10:39.310528Z",
"shell.execute_reply": "2024-08-02T09:10:39.309865Z"
},
"id": "gpSLs3Hx8viI"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"artifact: Artifact(artifact: id: 15\n",
"type_id: 14\n",
"uri: \"/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8\"\n",
"properties {\n",
" key: \"split_names\"\n",
" value {\n",
" string_value: \"[\\\"eval\\\", \\\"train\\\"]\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"name\"\n",
" value {\n",
" string_value: \"augmented_examples:2024-08-02T09:10:31.301021\"\n",
" }\n",
"}\n",
"custom_properties {\n",
" key: \"producer_component\"\n",
" value {\n",
" string_value: \"GraphAugmentation\"\n",
" }\n",
"}\n",
"name: \"augmented_examples:2024-08-02T09:10:31.301021\"\n",
", artifact_type: id: 14\n",
"name: \"Examples\"\n",
"properties {\n",
" key: \"span\"\n",
" value: INT\n",
"}\n",
"properties {\n",
" key: \"split_names\"\n",
" value: STRING\n",
"}\n",
"properties {\n",
" key: \"version\"\n",
" value: INT\n",
"}\n",
"base_type: DATASET\n",
")\n",
"uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8/Split-train\n",
"tfrecord_filenames: ['/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8/Split-train/nsl_train_data.tfr.gz']\n",
"features {\n",
" feature {\n",
" key: \"NL_num_nbrs\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"d7a8912a-cea4-4453-a79e-fbbe5785e9ee\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 8\n",
" value: 14\n",
" value: 32\n",
" value: 338\n",
" value: 310\n",
" value: 15\n",
" value: 95\n",
" value: 27\n",
" value: 10001\n",
" value: 9\n",
" value: 31\n",
" value: 1173\n",
" value: 3153\n",
" value: 43\n",
" value: 495\n",
" value: 10060\n",
" value: 214\n",
" value: 26\n",
" value: 71\n",
" value: 142\n",
" value: 19\n",
" value: 8\n",
" value: 204\n",
" value: 339\n",
" value: 27\n",
" value: 74\n",
" value: 181\n",
" value: 238\n",
" value: 9\n",
" value: 440\n",
" value: 67\n",
" value: 74\n",
" value: 71\n",
" value: 94\n",
" value: 100\n",
" value: 22\n",
" value: 5442\n",
" value: 8\n",
" value: 1573\n",
" value: 607\n",
" value: 530\n",
" value: 8\n",
" value: 15\n",
" value: 6\n",
" value: 32\n",
" value: 378\n",
" value: 6292\n",
" value: 207\n",
" value: 2276\n",
" value: 388\n",
" value: 0\n",
" value: 84\n",
" value: 1023\n",
" value: 154\n",
" value: 65\n",
" value: 155\n",
" value: 52\n",
" value: 0\n",
" value: 10080\n",
" value: 7871\n",
" value: 65\n",
" value: 250\n",
" value: 74\n",
" value: 3202\n",
" value: 20\n",
" value: 10000\n",
" value: 3720\n",
" value: 10020\n",
" value: 10008\n",
" value: 1282\n",
" value: 3862\n",
" value: 3\n",
" value: 53\n",
" value: 3952\n",
" value: 110\n",
" value: 1879\n",
" value: 17\n",
" value: 3153\n",
" value: 14\n",
" value: 166\n",
" value: 19\n",
" value: 2\n",
" value: 1023\n",
" value: 1007\n",
" value: 9405\n",
" value: 9\n",
" value: 2\n",
" value: 15\n",
" value: 12\n",
" value: 14\n",
" value: 4504\n",
" value: 4\n",
" value: 109\n",
" value: 158\n",
" value: 1202\n",
" value: 7\n",
" value: 174\n",
" value: 505\n",
" value: 12\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"features {\n",
" feature {\n",
" key: \"NL_num_nbrs\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"ed97ab48-01a6-46f7-81d7-2bf3f448ff22\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 7\n",
" value: 23\n",
" value: 75\n",
" value: 494\n",
" value: 5\n",
" value: 748\n",
" value: 2155\n",
" value: 307\n",
" value: 91\n",
" value: 19\n",
" value: 8\n",
" value: 6\n",
" value: 499\n",
" value: 763\n",
" value: 5\n",
" value: 2\n",
" value: 1690\n",
" value: 4\n",
" value: 200\n",
" value: 593\n",
" value: 57\n",
" value: 1244\n",
" value: 120\n",
" value: 2364\n",
" value: 3\n",
" value: 4407\n",
" value: 21\n",
" value: 0\n",
" value: 10081\n",
" value: 3\n",
" value: 263\n",
" value: 42\n",
" value: 6947\n",
" value: 2\n",
" value: 169\n",
" value: 185\n",
" value: 21\n",
" value: 8\n",
" value: 5143\n",
" value: 7\n",
" value: 1339\n",
" value: 2155\n",
" value: 81\n",
" value: 0\n",
" value: 18\n",
" value: 14\n",
" value: 1468\n",
" value: 0\n",
" value: 86\n",
" value: 986\n",
" value: 14\n",
" value: 2259\n",
" value: 1790\n",
" value: 562\n",
" value: 3\n",
" value: 284\n",
" value: 200\n",
" value: 401\n",
" value: 5\n",
" value: 668\n",
" value: 19\n",
" value: 17\n",
" value: 58\n",
" value: 1934\n",
" value: 4\n",
" value: 45\n",
" value: 14\n",
" value: 4212\n",
" value: 113\n",
" value: 43\n",
" value: 135\n",
" value: 7\n",
" value: 753\n",
" value: 7\n",
" value: 224\n",
" value: 23\n",
" value: 1155\n",
" value: 179\n",
" value: 4\n",
" value: 0\n",
" value: 18\n",
" value: 19\n",
" value: 7\n",
" value: 191\n",
" value: 0\n",
" value: 2047\n",
" value: 4\n",
" value: 10\n",
" value: 3\n",
" value: 283\n",
" value: 42\n",
" value: 401\n",
" value: 5\n",
" value: 668\n",
" value: 4\n",
" value: 90\n",
" value: 234\n",
" value: 10023\n",
" value: 227\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"features {\n",
" feature {\n",
" key: \"NL_num_nbrs\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"8fe0aa92-b194-4ed1-98e7-3f72be67ea75\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 4577\n",
" value: 7158\n",
" value: 0\n",
" value: 10047\n",
" value: 3778\n",
" value: 3346\n",
" value: 9\n",
" value: 2\n",
" value: 758\n",
" value: 1915\n",
" value: 3\n",
" value: 2280\n",
" value: 1511\n",
" value: 3\n",
" value: 2003\n",
" value: 10020\n",
" value: 225\n",
" value: 786\n",
" value: 382\n",
" value: 16\n",
" value: 39\n",
" value: 203\n",
" value: 361\n",
" value: 5\n",
" value: 93\n",
" value: 11\n",
" value: 11\n",
" value: 19\n",
" value: 220\n",
" value: 21\n",
" value: 341\n",
" value: 2\n",
" value: 10000\n",
" value: 966\n",
" value: 0\n",
" value: 77\n",
" value: 4\n",
" value: 6677\n",
" value: 464\n",
" value: 10071\n",
" value: 5\n",
" value: 10042\n",
" value: 630\n",
" value: 2\n",
" value: 10044\n",
" value: 404\n",
" value: 2\n",
" value: 10044\n",
" value: 3\n",
" value: 5\n",
" value: 10008\n",
" value: 0\n",
" value: 1259\n",
" value: 630\n",
" value: 106\n",
" value: 10042\n",
" value: 6721\n",
" value: 10\n",
" value: 49\n",
" value: 21\n",
" value: 0\n",
" value: 2071\n",
" value: 20\n",
" value: 1292\n",
" value: 4\n",
" value: 0\n",
" value: 431\n",
" value: 11\n",
" value: 11\n",
" value: 166\n",
" value: 67\n",
" value: 2342\n",
" value: 5815\n",
" value: 12\n",
" value: 575\n",
" value: 21\n",
" value: 0\n",
" value: 1691\n",
" value: 537\n",
" value: 4\n",
" value: 0\n",
" value: 3605\n",
" value: 307\n",
" value: 0\n",
" value: 10054\n",
" value: 1563\n",
" value: 3115\n",
" value: 467\n",
" value: 4577\n",
" value: 3\n",
" value: 1069\n",
" value: 1158\n",
" value: 5\n",
" value: 23\n",
" value: 4279\n",
" value: 6677\n",
" value: 464\n",
" value: 20\n",
" value: 10004\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"features {\n",
" feature {\n",
" key: \"NL_num_nbrs\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"66bc21ee-32ed-486e-8c16-ccca8252442c\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 1\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 8\n",
" value: 6\n",
" value: 0\n",
" value: 251\n",
" value: 4\n",
" value: 18\n",
" value: 20\n",
" value: 2\n",
" value: 6783\n",
" value: 2295\n",
" value: 2338\n",
" value: 52\n",
" value: 0\n",
" value: 468\n",
" value: 4\n",
" value: 0\n",
" value: 189\n",
" value: 73\n",
" value: 153\n",
" value: 1294\n",
" value: 17\n",
" value: 90\n",
" value: 234\n",
" value: 935\n",
" value: 16\n",
" value: 25\n",
" value: 10024\n",
" value: 92\n",
" value: 2\n",
" value: 192\n",
" value: 4218\n",
" value: 3317\n",
" value: 3\n",
" value: 10098\n",
" value: 20\n",
" value: 2\n",
" value: 356\n",
" value: 4\n",
" value: 565\n",
" value: 334\n",
" value: 382\n",
" value: 36\n",
" value: 6989\n",
" value: 3\n",
" value: 6065\n",
" value: 2510\n",
" value: 16\n",
" value: 203\n",
" value: 7264\n",
" value: 2849\n",
" value: 0\n",
" value: 86\n",
" value: 346\n",
" value: 50\n",
" value: 26\n",
" value: 58\n",
" value: 10020\n",
" value: 5\n",
" value: 1464\n",
" value: 58\n",
" value: 2081\n",
" value: 2969\n",
" value: 42\n",
" value: 2\n",
" value: 2364\n",
" value: 3\n",
" value: 1402\n",
" value: 10062\n",
" value: 138\n",
" value: 147\n",
" value: 614\n",
" value: 115\n",
" value: 29\n",
" value: 90\n",
" value: 105\n",
" value: 2\n",
" value: 223\n",
" value: 18\n",
" value: 9\n",
" value: 160\n",
" value: 324\n",
" value: 3\n",
" value: 24\n",
" value: 12\n",
" value: 1252\n",
" value: 0\n",
" value: 2142\n",
" value: 10\n",
" value: 1832\n",
" value: 111\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"features {\n",
" feature {\n",
" key: \"NL_num_nbrs\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"036e6ead-d36e-4fa3-83ad-15b1f66250c2\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 1\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 16\n",
" value: 423\n",
" value: 23\n",
" value: 1367\n",
" value: 30\n",
" value: 0\n",
" value: 363\n",
" value: 12\n",
" value: 153\n",
" value: 3174\n",
" value: 9\n",
" value: 8\n",
" value: 18\n",
" value: 26\n",
" value: 667\n",
" value: 338\n",
" value: 1372\n",
" value: 0\n",
" value: 86\n",
" value: 46\n",
" value: 9200\n",
" value: 282\n",
" value: 0\n",
" value: 10091\n",
" value: 4\n",
" value: 0\n",
" value: 694\n",
" value: 10028\n",
" value: 52\n",
" value: 362\n",
" value: 26\n",
" value: 202\n",
" value: 39\n",
" value: 216\n",
" value: 5\n",
" value: 27\n",
" value: 5822\n",
" value: 19\n",
" value: 52\n",
" value: 58\n",
" value: 362\n",
" value: 26\n",
" value: 202\n",
" value: 39\n",
" value: 474\n",
" value: 0\n",
" value: 10029\n",
" value: 4\n",
" value: 2\n",
" value: 243\n",
" value: 143\n",
" value: 386\n",
" value: 3\n",
" value: 0\n",
" value: 386\n",
" value: 579\n",
" value: 2\n",
" value: 132\n",
" value: 57\n",
" value: 725\n",
" value: 88\n",
" value: 140\n",
" value: 30\n",
" value: 27\n",
" value: 33\n",
" value: 1359\n",
" value: 29\n",
" value: 8\n",
" value: 567\n",
" value: 35\n",
" value: 106\n",
" value: 230\n",
" value: 60\n",
" value: 0\n",
" value: 3041\n",
" value: 5\n",
" value: 7879\n",
" value: 28\n",
" value: 281\n",
" value: 110\n",
" value: 111\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" value: 1\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n",
"features {\n",
" feature {\n",
" key: \"NL_num_nbrs\"\n",
" value {\n",
" int64_list {\n",
" value: 0\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"id\"\n",
" value {\n",
" bytes_list {\n",
" value: \"3ba1a554-cd8d-4095-8185-d2d0a04ec5bb\"\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"label_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 1\n",
" }\n",
" }\n",
" }\n",
" feature {\n",
" key: \"text_xf\"\n",
" value {\n",
" int64_list {\n",
" value: 13\n",
" value: 8\n",
" value: 6\n",
" value: 2\n",
" value: 18\n",
" value: 69\n",
" value: 140\n",
" value: 27\n",
" value: 83\n",
" value: 31\n",
" value: 1877\n",
" value: 905\n",
" value: 9\n",
" value: 10057\n",
" value: 31\n",
" value: 43\n",
" value: 2115\n",
" value: 36\n",
" value: 32\n",
" value: 2057\n",
" value: 6133\n",
" value: 10\n",
" value: 6\n",
" value: 32\n",
" value: 2474\n",
" value: 1614\n",
" value: 3\n",
" value: 2707\n",
" value: 990\n",
" value: 4\n",
" value: 10067\n",
" value: 9\n",
" value: 2\n",
" value: 1532\n",
" value: 242\n",
" value: 90\n",
" value: 3757\n",
" value: 3\n",
" value: 90\n",
" value: 10026\n",
" value: 0\n",
" value: 242\n",
" value: 6\n",
" value: 260\n",
" value: 31\n",
" value: 24\n",
" value: 4\n",
" value: 0\n",
" value: 84\n",
" value: 497\n",
" value: 177\n",
" value: 1151\n",
" value: 777\n",
" value: 9\n",
" value: 397\n",
" value: 552\n",
" value: 7726\n",
" value: 10051\n",
" value: 34\n",
" value: 14\n",
" value: 379\n",
" value: 33\n",
" value: 1829\n",
" value: 9\n",
" value: 123\n",
" value: 0\n",
" value: 916\n",
" value: 10028\n",
" value: 7\n",
" value: 64\n",
" value: 571\n",
" value: 12\n",
" value: 8\n",
" value: 18\n",
" value: 27\n",
" value: 687\n",
" value: 9\n",
" value: 30\n",
" value: 5609\n",
" value: 16\n",
" value: 25\n",
" value: 99\n",
" value: 117\n",
" value: 66\n",
" value: 2\n",
" value: 130\n",
" value: 21\n",
" value: 8\n",
" value: 842\n",
" value: 7726\n",
" value: 10051\n",
" value: 6\n",
" value: 338\n",
" value: 1107\n",
" value: 3\n",
" value: 24\n",
" value: 10020\n",
" value: 29\n",
" value: 53\n",
" value: 1476\n",
" }\n",
" }\n",
" }\n",
"}\n",
"\n"
]
}
],
"source": [
"pprint_examples(graph_augmentation.outputs['augmented_examples'].get()[0], 6)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "OBJFtnl6lCg9"
},
"source": [
"### The Trainer Component\n",
"\n",
"The `Trainer` component trains models using TensorFlow.\n",
"\n",
"Create a Python module containing a `trainer_fn` function, which must return an estimator. If you prefer creating a Keras model, you can do so and then convert it to an estimator using `keras.model_to_estimator()`."
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:39.314229Z",
"iopub.status.busy": "2024-08-02T09:10:39.313565Z",
"iopub.status.idle": "2024-08-02T09:10:39.316938Z",
"shell.execute_reply": "2024-08-02T09:10:39.316290Z"
},
"id": "5ajvClE6b2pd"
},
"outputs": [],
"source": [
"# Setup paths.\n",
"_trainer_module_file = 'imdb_trainer.py'"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:39.320801Z",
"iopub.status.busy": "2024-08-02T09:10:39.320422Z",
"iopub.status.idle": "2024-08-02T09:10:39.333869Z",
"shell.execute_reply": "2024-08-02T09:10:39.333186Z"
},
"id": "_dh6AejVk2Oq"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Writing imdb_trainer.py\n"
]
}
],
"source": [
"%%writefile {_trainer_module_file}\n",
"\n",
"import neural_structured_learning as nsl\n",
"\n",
"import tensorflow as tf\n",
"\n",
"import tensorflow_model_analysis as tfma\n",
"import tensorflow_transform as tft\n",
"from tensorflow_transform.tf_metadata import schema_utils\n",
"\n",
"\n",
"NBR_FEATURE_PREFIX = 'NL_nbr_'\n",
"NBR_WEIGHT_SUFFIX = '_weight'\n",
"LABEL_KEY = 'label'\n",
"ID_FEATURE_KEY = 'id'\n",
"\n",
"def _transformed_name(key):\n",
" return key + '_xf'\n",
"\n",
"\n",
"def _transformed_names(keys):\n",
" return [_transformed_name(key) for key in keys]\n",
"\n",
"\n",
"# Hyperparameters:\n",
"#\n",
"# We will use an instance of `HParams` to inclue various hyperparameters and\n",
"# constants used for training and evaluation. We briefly describe each of them\n",
"# below:\n",
"#\n",
"# - max_seq_length: This is the maximum number of words considered from each\n",
"# movie review in this example.\n",
"# - vocab_size: This is the size of the vocabulary considered for this\n",
"# example.\n",
"# - oov_size: This is the out-of-vocabulary size considered for this example.\n",
"# - distance_type: This is the distance metric used to regularize the sample\n",
"# with its neighbors.\n",
"# - graph_regularization_multiplier: This controls the relative weight of the\n",
"# graph regularization term in the overall\n",
"# loss function.\n",
"# - num_neighbors: The number of neighbors used for graph regularization. This\n",
"# value has to be less than or equal to the `num_neighbors`\n",
"# argument used above in the GraphAugmentation component when\n",
"# invoking `nsl.tools.pack_nbrs`.\n",
"# - num_fc_units: The number of units in the fully connected layer of the\n",
"# neural network.\n",
"class HParams(object):\n",
" \"\"\"Hyperparameters used for training.\"\"\"\n",
" def __init__(self):\n",
" ### dataset parameters\n",
" # The following 3 values should match those defined in the Transform\n",
" # Component.\n",
" self.max_seq_length = 100\n",
" self.vocab_size = 10000\n",
" self.oov_size = 100\n",
" ### Neural Graph Learning parameters\n",
" self.distance_type = nsl.configs.DistanceType.L2\n",
" self.graph_regularization_multiplier = 0.1\n",
" # The following value has to be at most the value of 'num_neighbors' used\n",
" # in the GraphAugmentation component.\n",
" self.num_neighbors = 1\n",
" ### Model Architecture\n",
" self.num_embedding_dims = 16\n",
" self.num_fc_units = 64\n",
"\n",
"HPARAMS = HParams()\n",
"\n",
"\n",
"def optimizer_fn():\n",
" \"\"\"Returns an instance of `tf.Optimizer`.\"\"\"\n",
" return tf.compat.v1.train.RMSPropOptimizer(\n",
" learning_rate=0.0001, decay=1e-6)\n",
"\n",
"\n",
"def build_train_op(loss, global_step):\n",
" \"\"\"Builds a train op to optimize the given loss using gradient descent.\"\"\"\n",
" with tf.name_scope('train'):\n",
" optimizer = optimizer_fn()\n",
" train_op = optimizer.minimize(loss=loss, global_step=global_step)\n",
" return train_op\n",
"\n",
"\n",
"# Building the model:\n",
"#\n",
"# A neural network is created by stacking layers—this requires two main\n",
"# architectural decisions:\n",
"# * How many layers to use in the model?\n",
"# * How many *hidden units* to use for each layer?\n",
"#\n",
"# In this example, the input data consists of an array of word-indices. The\n",
"# labels to predict are either 0 or 1. We will use a feed-forward neural network\n",
"# as our base model in this tutorial.\n",
"def feed_forward_model(features, is_training, reuse=tf.compat.v1.AUTO_REUSE):\n",
" \"\"\"Builds a simple 2 layer feed forward neural network.\n",
"\n",
" The layers are effectively stacked sequentially to build the classifier. The\n",
" first layer is an Embedding layer, which takes the integer-encoded vocabulary\n",
" and looks up the embedding vector for each word-index. These vectors are\n",
" learned as the model trains. The vectors add a dimension to the output array.\n",
" The resulting dimensions are: (batch, sequence, embedding). Next is a global\n",
" average pooling 1D layer, which reduces the dimensionality of its inputs from\n",
" 3D to 2D. This fixed-length output vector is piped through a fully-connected\n",
" (Dense) layer with 16 hidden units. The last layer is densely connected with a\n",
" single output node. Using the sigmoid activation function, this value is a\n",
" float between 0 and 1, representing a probability, or confidence level.\n",
"\n",
" Args:\n",
" features: A dictionary containing batch features returned from the\n",
" `input_fn`, that include sample features, corresponding neighbor features,\n",
" and neighbor weights.\n",
" is_training: a Python Boolean value or a Boolean scalar Tensor, indicating\n",
" whether to apply dropout.\n",
" reuse: a Python Boolean value for reusing variable scope.\n",
"\n",
" Returns:\n",
" logits: Tensor of shape [batch_size, 1].\n",
" representations: Tensor of shape [batch_size, _] for graph regularization.\n",
" This is the representation of each example at the graph regularization\n",
" layer.\n",
" \"\"\"\n",
"\n",
" with tf.compat.v1.variable_scope('ff', reuse=reuse):\n",
" inputs = features[_transformed_name('text')]\n",
" embeddings = tf.compat.v1.get_variable(\n",
" 'embeddings',\n",
" shape=[\n",
" HPARAMS.vocab_size + HPARAMS.oov_size, HPARAMS.num_embedding_dims\n",
" ])\n",
" embedding_layer = tf.nn.embedding_lookup(embeddings, inputs)\n",
"\n",
" pooling_layer = tf.compat.v1.layers.AveragePooling1D(\n",
" pool_size=HPARAMS.max_seq_length, strides=HPARAMS.max_seq_length)(\n",
" embedding_layer)\n",
" # Shape of pooling_layer is now [batch_size, 1, HPARAMS.num_embedding_dims]\n",
" pooling_layer = tf.reshape(pooling_layer, [-1, HPARAMS.num_embedding_dims])\n",
"\n",
" dense_layer = tf.compat.v1.layers.Dense(\n",
" 16, activation='relu')(\n",
" pooling_layer)\n",
"\n",
" output_layer = tf.compat.v1.layers.Dense(\n",
" 1, activation='sigmoid')(\n",
" dense_layer)\n",
"\n",
" # Graph regularization will be done on the penultimate (dense) layer\n",
" # because the output layer is a single floating point number.\n",
" return output_layer, dense_layer\n",
"\n",
"\n",
"# A note on hidden units:\n",
"#\n",
"# The above model has two intermediate or \"hidden\" layers, between the input and\n",
"# output, and excluding the Embedding layer. The number of outputs (units,\n",
"# nodes, or neurons) is the dimension of the representational space for the\n",
"# layer. In other words, the amount of freedom the network is allowed when\n",
"# learning an internal representation. If a model has more hidden units\n",
"# (a higher-dimensional representation space), and/or more layers, then the\n",
"# network can learn more complex representations. However, it makes the network\n",
"# more computationally expensive and may lead to learning unwanted\n",
"# patterns—patterns that improve performance on training data but not on the\n",
"# test data. This is called overfitting.\n",
"\n",
"\n",
"# This function will be used to generate the embeddings for samples and their\n",
"# corresponding neighbors, which will then be used for graph regularization.\n",
"def embedding_fn(features, mode, **params):\n",
" \"\"\"Returns the embedding corresponding to the given features.\n",
"\n",
" Args:\n",
" features: A dictionary containing batch features returned from the\n",
" `input_fn`, that include sample features, corresponding neighbor features,\n",
" and neighbor weights.\n",
" mode: Specifies if this is training, evaluation, or prediction. See\n",
" tf.estimator.ModeKeys.\n",
"\n",
" Returns:\n",
" The embedding that will be used for graph regularization.\n",
" \"\"\"\n",
" is_training = (mode == tf.estimator.ModeKeys.TRAIN)\n",
" _, embedding = feed_forward_model(features, is_training)\n",
" return embedding\n",
"\n",
"\n",
"def feed_forward_model_fn(features, labels, mode, params, config):\n",
" \"\"\"Implementation of the model_fn for the base feed-forward model.\n",
"\n",
" Args:\n",
" features: This is the first item returned from the `input_fn` passed to\n",
" `train`, `evaluate`, and `predict`. This should be a single `Tensor` or\n",
" `dict` of same.\n",
" labels: This is the second item returned from the `input_fn` passed to\n",
" `train`, `evaluate`, and `predict`. This should be a single `Tensor` or\n",
" `dict` of same (for multi-head models). If mode is `ModeKeys.PREDICT`,\n",
" `labels=None` will be passed. If the `model_fn`'s signature does not\n",
" accept `mode`, the `model_fn` must still be able to handle `labels=None`.\n",
" mode: Optional. Specifies if this training, evaluation or prediction. See\n",
" `ModeKeys`.\n",
" params: An HParams instance as returned by get_hyper_parameters().\n",
" config: Optional configuration object. Will receive what is passed to\n",
" Estimator in `config` parameter, or the default `config`. Allows updating\n",
" things in your model_fn based on configuration such as `num_ps_replicas`,\n",
" or `model_dir`. Unused currently.\n",
"\n",
" Returns:\n",
" A `tf.estimator.EstimatorSpec` for the base feed-forward model. This does\n",
" not include graph-based regularization.\n",
" \"\"\"\n",
"\n",
" is_training = mode == tf.estimator.ModeKeys.TRAIN\n",
"\n",
" # Build the computation graph.\n",
" probabilities, _ = feed_forward_model(features, is_training)\n",
" predictions = tf.round(probabilities)\n",
"\n",
" if mode == tf.estimator.ModeKeys.PREDICT:\n",
" # labels will be None, and no loss to compute.\n",
" cross_entropy_loss = None\n",
" eval_metric_ops = None\n",
" else:\n",
" # Loss is required in train and eval modes.\n",
" # Flatten 'probabilities' to 1-D.\n",
" probabilities = tf.reshape(probabilities, shape=[-1])\n",
" cross_entropy_loss = tf.compat.v1.keras.losses.binary_crossentropy(\n",
" labels, probabilities)\n",
" eval_metric_ops = {\n",
" 'accuracy': tf.compat.v1.metrics.accuracy(labels, predictions)\n",
" }\n",
"\n",
" if is_training:\n",
" global_step = tf.compat.v1.train.get_or_create_global_step()\n",
" train_op = build_train_op(cross_entropy_loss, global_step)\n",
" else:\n",
" train_op = None\n",
"\n",
" return tf.estimator.EstimatorSpec(\n",
" mode=mode,\n",
" predictions={\n",
" 'probabilities': probabilities,\n",
" 'predictions': predictions\n",
" },\n",
" loss=cross_entropy_loss,\n",
" train_op=train_op,\n",
" eval_metric_ops=eval_metric_ops)\n",
"\n",
"\n",
"# Tf.Transform considers these features as \"raw\"\n",
"def _get_raw_feature_spec(schema):\n",
" return schema_utils.schema_as_feature_spec(schema).feature_spec\n",
"\n",
"\n",
"def _gzip_reader_fn(filenames):\n",
" \"\"\"Small utility returning a record reader that can read gzip'ed files.\"\"\"\n",
" return tf.data.TFRecordDataset(\n",
" filenames,\n",
" compression_type='GZIP')\n",
"\n",
"\n",
"def _example_serving_receiver_fn(tf_transform_output, schema):\n",
" \"\"\"Build the serving in inputs.\n",
"\n",
" Args:\n",
" tf_transform_output: A TFTransformOutput.\n",
" schema: the schema of the input data.\n",
"\n",
" Returns:\n",
" Tensorflow graph which parses examples, applying tf-transform to them.\n",
" \"\"\"\n",
" raw_feature_spec = _get_raw_feature_spec(schema)\n",
" raw_feature_spec.pop(LABEL_KEY)\n",
"\n",
" # We don't need the ID feature for serving.\n",
" raw_feature_spec.pop(ID_FEATURE_KEY)\n",
"\n",
" raw_input_fn = tf.estimator.export.build_parsing_serving_input_receiver_fn(\n",
" raw_feature_spec, default_batch_size=None)\n",
" serving_input_receiver = raw_input_fn()\n",
"\n",
" transformed_features = tf_transform_output.transform_raw_features(\n",
" serving_input_receiver.features)\n",
"\n",
" # Even though, LABEL_KEY was removed from 'raw_feature_spec', the transform\n",
" # operation would have injected the transformed LABEL_KEY feature with a\n",
" # default value.\n",
" transformed_features.pop(_transformed_name(LABEL_KEY))\n",
" return tf.estimator.export.ServingInputReceiver(\n",
" transformed_features, serving_input_receiver.receiver_tensors)\n",
"\n",
"\n",
"def _eval_input_receiver_fn(tf_transform_output, schema):\n",
" \"\"\"Build everything needed for the tf-model-analysis to run the model.\n",
"\n",
" Args:\n",
" tf_transform_output: A TFTransformOutput.\n",
" schema: the schema of the input data.\n",
"\n",
" Returns:\n",
" EvalInputReceiver function, which contains:\n",
" - Tensorflow graph which parses raw untransformed features, applies the\n",
" tf-transform preprocessing operators.\n",
" - Set of raw, untransformed features.\n",
" - Label against which predictions will be compared.\n",
" \"\"\"\n",
" # Notice that the inputs are raw features, not transformed features here.\n",
" raw_feature_spec = _get_raw_feature_spec(schema)\n",
"\n",
" # We don't need the ID feature for TFMA.\n",
" raw_feature_spec.pop(ID_FEATURE_KEY)\n",
"\n",
" raw_input_fn = tf.estimator.export.build_parsing_serving_input_receiver_fn(\n",
" raw_feature_spec, default_batch_size=None)\n",
" serving_input_receiver = raw_input_fn()\n",
"\n",
" transformed_features = tf_transform_output.transform_raw_features(\n",
" serving_input_receiver.features)\n",
"\n",
" labels = transformed_features.pop(_transformed_name(LABEL_KEY))\n",
" return tfma.export.EvalInputReceiver(\n",
" features=transformed_features,\n",
" receiver_tensors=serving_input_receiver.receiver_tensors,\n",
" labels=labels)\n",
"\n",
"\n",
"def _augment_feature_spec(feature_spec, num_neighbors):\n",
" \"\"\"Augments `feature_spec` to include neighbor features.\n",
" Args:\n",
" feature_spec: Dictionary of feature keys mapping to TF feature types.\n",
" num_neighbors: Number of neighbors to use for feature key augmentation.\n",
" Returns:\n",
" An augmented `feature_spec` that includes neighbor feature keys.\n",
" \"\"\"\n",
" for i in range(num_neighbors):\n",
" feature_spec['{}{}_{}'.format(NBR_FEATURE_PREFIX, i, 'id')] = \\\n",
" tf.io.VarLenFeature(dtype=tf.string)\n",
" # We don't care about the neighbor features corresponding to\n",
" # _transformed_name(LABEL_KEY) because the LABEL_KEY feature will be\n",
" # removed from the feature spec during training/evaluation.\n",
" feature_spec['{}{}_{}'.format(NBR_FEATURE_PREFIX, i, 'text_xf')] = \\\n",
" tf.io.FixedLenFeature(shape=[HPARAMS.max_seq_length], dtype=tf.int64,\n",
" default_value=tf.constant(0, dtype=tf.int64,\n",
" shape=[HPARAMS.max_seq_length]))\n",
" # The 'NL_num_nbrs' features is currently not used.\n",
"\n",
" # Set the neighbor weight feature keys.\n",
" for i in range(num_neighbors):\n",
" feature_spec['{}{}{}'.format(NBR_FEATURE_PREFIX, i, NBR_WEIGHT_SUFFIX)] = \\\n",
" tf.io.FixedLenFeature(shape=[1], dtype=tf.float32, default_value=[0.0])\n",
"\n",
" return feature_spec\n",
"\n",
"\n",
"def _input_fn(filenames, tf_transform_output, is_training, batch_size=200):\n",
" \"\"\"Generates features and labels for training or evaluation.\n",
"\n",
" Args:\n",
" filenames: [str] list of CSV files to read data from.\n",
" tf_transform_output: A TFTransformOutput.\n",
" is_training: Boolean indicating if we are in training mode.\n",
" batch_size: int First dimension size of the Tensors returned by input_fn\n",
"\n",
" Returns:\n",
" A (features, indices) tuple where features is a dictionary of\n",
" Tensors, and indices is a single Tensor of label indices.\n",
" \"\"\"\n",
" transformed_feature_spec = (\n",
" tf_transform_output.transformed_feature_spec().copy())\n",
"\n",
" # During training, NSL uses augmented training data (which includes features\n",
" # from graph neighbors). So, update the feature spec accordingly. This needs\n",
" # to be done because we are using different schemas for NSL training and eval,\n",
" # but the Trainer Component only accepts a single schema.\n",
" if is_training:\n",
" transformed_feature_spec =_augment_feature_spec(transformed_feature_spec,\n",
" HPARAMS.num_neighbors)\n",
"\n",
" dataset = tf.data.experimental.make_batched_features_dataset(\n",
" filenames, batch_size, transformed_feature_spec, reader=_gzip_reader_fn)\n",
"\n",
" transformed_features = tf.compat.v1.data.make_one_shot_iterator(\n",
" dataset).get_next()\n",
" # We pop the label because we do not want to use it as a feature while we're\n",
" # training.\n",
" return transformed_features, transformed_features.pop(\n",
" _transformed_name(LABEL_KEY))\n",
"\n",
"\n",
"# TFX will call this function\n",
"def trainer_fn(hparams, schema):\n",
" \"\"\"Build the estimator using the high level API.\n",
" Args:\n",
" hparams: Holds hyperparameters used to train the model as name/value pairs.\n",
" schema: Holds the schema of the training examples.\n",
" Returns:\n",
" A dict of the following:\n",
" - estimator: The estimator that will be used for training and eval.\n",
" - train_spec: Spec for training.\n",
" - eval_spec: Spec for eval.\n",
" - eval_input_receiver_fn: Input function for eval.\n",
" \"\"\"\n",
" train_batch_size = 40\n",
" eval_batch_size = 40\n",
"\n",
" tf_transform_output = tft.TFTransformOutput(hparams.transform_output)\n",
"\n",
" train_input_fn = lambda: _input_fn(\n",
" hparams.train_files,\n",
" tf_transform_output,\n",
" is_training=True,\n",
" batch_size=train_batch_size)\n",
"\n",
" eval_input_fn = lambda: _input_fn(\n",
" hparams.eval_files,\n",
" tf_transform_output,\n",
" is_training=False,\n",
" batch_size=eval_batch_size)\n",
"\n",
" train_spec = tf.estimator.TrainSpec(\n",
" train_input_fn,\n",
" max_steps=hparams.train_steps)\n",
"\n",
" serving_receiver_fn = lambda: _example_serving_receiver_fn(\n",
" tf_transform_output, schema)\n",
"\n",
" exporter = tf.estimator.FinalExporter('imdb', serving_receiver_fn)\n",
" eval_spec = tf.estimator.EvalSpec(\n",
" eval_input_fn,\n",
" steps=hparams.eval_steps,\n",
" exporters=[exporter],\n",
" name='imdb-eval')\n",
"\n",
" run_config = tf.estimator.RunConfig(\n",
" save_checkpoints_steps=999, keep_checkpoint_max=1)\n",
"\n",
" run_config = run_config.replace(model_dir=hparams.serving_model_dir)\n",
"\n",
" estimator = tf.estimator.Estimator(\n",
" model_fn=feed_forward_model_fn, config=run_config, params=HPARAMS)\n",
"\n",
" # Create a graph regularization config.\n",
" graph_reg_config = nsl.configs.make_graph_reg_config(\n",
" max_neighbors=HPARAMS.num_neighbors,\n",
" multiplier=HPARAMS.graph_regularization_multiplier,\n",
" distance_type=HPARAMS.distance_type,\n",
" sum_over_axis=-1)\n",
"\n",
" # Invoke the Graph Regularization Estimator wrapper to incorporate\n",
" # graph-based regularization for training.\n",
" graph_nsl_estimator = nsl.estimator.add_graph_regularization(\n",
" estimator,\n",
" embedding_fn,\n",
" optimizer_fn=optimizer_fn,\n",
" graph_reg_config=graph_reg_config)\n",
"\n",
" # Create an input receiver for TFMA processing\n",
" receiver_fn = lambda: _eval_input_receiver_fn(\n",
" tf_transform_output, schema)\n",
"\n",
" return {\n",
" 'estimator': graph_nsl_estimator,\n",
" 'train_spec': train_spec,\n",
" 'eval_spec': eval_spec,\n",
" 'eval_input_receiver_fn': receiver_fn\n",
" }"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "GnLjStUJIoos"
},
"source": [
"Create and run the `Trainer` component, passing it the file that we created above."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:10:39.337314Z",
"iopub.status.busy": "2024-08-02T09:10:39.336776Z",
"iopub.status.idle": "2024-08-02T09:11:30.357794Z",
"shell.execute_reply": "2024-08-02T09:11:30.357165Z"
},
"id": "MWLQI6t0b2pg"
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:`custom_executor_spec` is deprecated. Please customize component directly.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:`transformed_examples` is deprecated. Please use `examples` instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"running bdist_wheel\n",
"running build\n",
"running build_py\n",
"creating build\n",
"creating build/lib\n",
"copying imdb_trainer.py -> build/lib\n",
"copying imdb_transform.py -> build/lib\n",
"installing to /tmpfs/tmp/tmpn8qeu_e6\n",
"running install\n",
"running install_lib\n",
"copying build/lib/imdb_trainer.py -> /tmpfs/tmp/tmpn8qeu_e6\n",
"copying build/lib/imdb_transform.py -> /tmpfs/tmp/tmpn8qeu_e6\n",
"running install_egg_info\n",
"running egg_info\n",
"creating tfx_user_code_Trainer.egg-info\n",
"writing tfx_user_code_Trainer.egg-info/PKG-INFO\n",
"writing dependency_links to tfx_user_code_Trainer.egg-info/dependency_links.txt\n",
"writing top-level names to tfx_user_code_Trainer.egg-info/top_level.txt\n",
"writing manifest file 'tfx_user_code_Trainer.egg-info/SOURCES.txt'\n",
"reading manifest file 'tfx_user_code_Trainer.egg-info/SOURCES.txt'\n",
"writing manifest file 'tfx_user_code_Trainer.egg-info/SOURCES.txt'\n",
"Copying tfx_user_code_Trainer.egg-info to /tmpfs/tmp/tmpn8qeu_e6/tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9-py3.9.egg-info\n",
"running install_scripts\n",
"creating /tmpfs/tmp/tmpn8qeu_e6/tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9.dist-info/WHEEL\n",
"creating '/tmpfs/tmp/tmpz0q698_l/tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9-py3-none-any.whl' and adding '/tmpfs/tmp/tmpn8qeu_e6' to it\n",
"adding 'imdb_trainer.py'\n",
"adding 'imdb_transform.py'\n",
"adding 'tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9.dist-info/METADATA'\n",
"adding 'tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9.dist-info/WHEEL'\n",
"adding 'tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9.dist-info/top_level.txt'\n",
"adding 'tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9.dist-info/RECORD'\n",
"removing /tmpfs/tmp/tmpn8qeu_e6\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmpfs/src/tf_docs_env/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.\n",
"!!\n",
"\n",
" ********************************************************************************\n",
" Please avoid running ``setup.py`` directly.\n",
" Instead, use pypa/build, pypa/installer or other\n",
" standards-based tools.\n",
"\n",
" See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.\n",
" ********************************************************************************\n",
"\n",
"!!\n",
" self.initialize_options()\n",
"WARNING:absl:Examples artifact does not have payload_format custom property. Falling back to FORMAT_TF_EXAMPLE\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:Examples artifact does not have payload_format custom property. Falling back to FORMAT_TF_EXAMPLE\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:Examples artifact does not have payload_format custom property. Falling back to FORMAT_TF_EXAMPLE\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/_wheels/tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9-py3-none-any.whl\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Installing collected packages: tfx-user-code-Trainer\n",
"Successfully installed tfx-user-code-Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9\n",
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:415: TrainSpec.__new__ (from tensorflow_estimator.python.estimator.training) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:415: TrainSpec.__new__ (from tensorflow_estimator.python.estimator.training) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:422: FinalExporter.__init__ (from tensorflow_estimator.python.estimator.exporter) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:422: FinalExporter.__init__ (from tensorflow_estimator.python.estimator.exporter) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:423: EvalSpec.__new__ (from tensorflow_estimator.python.estimator.training) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:423: EvalSpec.__new__ (from tensorflow_estimator.python.estimator.training) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:429: RunConfig.__init__ (from tensorflow_estimator.python.estimator.run_config) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:429: RunConfig.__init__ (from tensorflow_estimator.python.estimator.run_config) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:434: Estimator.__init__ (from tensorflow_estimator.python.estimator.estimator) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:434: Estimator.__init__ (from tensorflow_estimator.python.estimator.estimator) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Using config: {'_model_dir': '/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': 999, '_save_checkpoints_secs': None, '_session_config': allow_soft_placement: true\n",
"graph_options {\n",
" rewrite_options {\n",
" meta_optimizer_iterations: ONE\n",
" }\n",
"}\n",
", '_keep_checkpoint_max': 1, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_checkpoint_save_graph_def': True, '_service': None, '_cluster_spec': ClusterSpec({}), '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Using config: {'_model_dir': '/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': 999, '_save_checkpoints_secs': None, '_session_config': allow_soft_placement: true\n",
"graph_options {\n",
" rewrite_options {\n",
" meta_optimizer_iterations: ONE\n",
" }\n",
"}\n",
", '_keep_checkpoint_max': 1, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_checkpoint_save_graph_def': True, '_service': None, '_cluster_spec': ClusterSpec({}), '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tfx/components/trainer/executor.py:270: train_and_evaluate (from tensorflow_estimator.python.estimator.training) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tfx/components/trainer/executor.py:270: train_and_evaluate (from tensorflow_estimator.python.estimator.training) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Not using Distribute Coordinator.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Not using Distribute Coordinator.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running training and evaluation locally (non-distributed).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running training and evaluation locally (non-distributed).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 999 or save_checkpoints_secs None.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 999 or save_checkpoints_secs None.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:385: StopAtStepHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:385: StopAtStepHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/readers.py:1086: parse_example_dataset (from tensorflow.python.data.experimental.ops.parsing_ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use `tf.data.Dataset.map(tf.io.parse_example(...))` instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/data/experimental/ops/readers.py:1086: parse_example_dataset (from tensorflow.python.data.experimental.ops.parsing_ops) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use `tf.data.Dataset.map(tf.io.parse_example(...))` instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/rmsprop.py:188: calling Ones.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Call initializer instance with the dtype argument instead of passing it to the constructor\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/rmsprop.py:188: calling Ones.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Call initializer instance with the dtype argument instead of passing it to the constructor\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:234: EstimatorSpec.__new__ (from tensorflow_estimator.python.estimator.model_fn) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:234: EstimatorSpec.__new__ (from tensorflow_estimator.python.estimator.model_fn) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:1416: NanTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:1416: NanTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:1419: LoggingTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:1419: LoggingTensorHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/basic_session_run_hooks.py:232: SecondOrStepTimer.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/basic_session_run_hooks.py:232: SecondOrStepTimer.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:1456: CheckpointSaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/estimator.py:1456: CheckpointSaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Create CheckpointSaverHook.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Create CheckpointSaverHook.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:579: StepCounterHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:579: StepCounterHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:586: SummarySaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:586: SummarySaverHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Graph was finalized.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Graph was finalized.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running local_init_op.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running local_init_op.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done running local_init_op.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done running local_init_op.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 0...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 0...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 0 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 0 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 0...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 0...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:1455: SessionRunArgs.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:1455: SessionRunArgs.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:1454: SessionRunContext.__init__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:1454: SessionRunContext.__init__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:1474: SessionRunValues.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/monitored_session.py:1474: SessionRunValues.__new__ (from tensorflow.python.training.session_run_hook) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6926379, step = 0\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6926379, step = 0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 236.906\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 236.906\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6921074, step = 100 (0.424 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6921074, step = 100 (0.424 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.248\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.248\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.69257027, step = 200 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.69257027, step = 200 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.882\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.882\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6909442, step = 300 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6909442, step = 300 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 316.203\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 316.203\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6921983, step = 400 (0.316 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6921983, step = 400 (0.316 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.596\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.596\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.69022787, step = 500 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.69022787, step = 500 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.18\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.18\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6892664, step = 600 (0.314 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6892664, step = 600 (0.314 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.588\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.588\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.68911326, step = 700 (0.314 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.68911326, step = 700 (0.314 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.042\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.042\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.687594, step = 800 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.687594, step = 800 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.103\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.103\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6855315, step = 900 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6855315, step = 900 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 999...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 999...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 999 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 999 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/saver.py:1067: remove_checkpoint (from tensorflow.python.checkpoint.checkpoint_management) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use standard file APIs to delete files with this prefix.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/saver.py:1067: remove_checkpoint (from tensorflow.python.checkpoint.checkpoint_management) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use standard file APIs to delete files with this prefix.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 999...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 999...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Starting evaluation at 2024-08-02T09:10:47\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Starting evaluation at 2024-08-02T09:10:47\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/evaluation.py:260: FinalOpsHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/training/evaluation.py:260: FinalOpsHook.__init__ (from tensorflow.python.training.basic_session_run_hooks) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Graph was finalized.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Graph was finalized.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-999\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-999\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running local_init_op.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running local_init_op.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done running local_init_op.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done running local_init_op.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [5000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [5000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Inference Time : 5.73905s\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Inference Time : 5.73905s\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Finished evaluation at 2024-08-02-09:10:53\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Finished evaluation at 2024-08-02-09:10:53\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving dict for global step 999: accuracy = 0.6908, global_step = 999, loss = 0.6853454\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving dict for global step 999: accuracy = 0.6908, global_step = 999, loss = 0.6853454\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving 'checkpoint_path' summary for global step 999: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-999\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving 'checkpoint_path' summary for global step 999: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-999\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 15.8738\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 15.8738\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6862798, step = 1000 (6.299 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6862798, step = 1000 (6.299 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.591\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.591\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.67689043, step = 1100 (0.317 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.67689043, step = 1100 (0.317 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.377\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.377\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6791981, step = 1200 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6791981, step = 1200 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.735\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.735\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6798181, step = 1300 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6798181, step = 1300 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.429\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.429\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6831201, step = 1400 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6831201, step = 1400 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.614\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.614\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6692234, step = 1500 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6692234, step = 1500 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.971\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.971\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6705712, step = 1600 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6705712, step = 1600 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.683\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.683\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6775126, step = 1700 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6775126, step = 1700 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.435\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.435\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.66159755, step = 1800 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.66159755, step = 1800 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 316.98\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 316.98\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.67395145, step = 1900 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.67395145, step = 1900 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 1998...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 1998...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 1998 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 1998 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 1998...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 1998...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 262.181\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 262.181\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6646619, step = 2000 (0.381 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6646619, step = 2000 (0.381 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.946\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.946\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6545558, step = 2100 (0.309 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6545558, step = 2100 (0.309 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.492\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.492\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.66675496, step = 2200 (0.314 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.66675496, step = 2200 (0.314 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.536\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.536\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.64969677, step = 2300 (0.309 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.64969677, step = 2300 (0.309 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.748\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.748\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.64181495, step = 2400 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.64181495, step = 2400 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.284\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.284\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6472198, step = 2500 (0.309 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6472198, step = 2500 (0.309 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.331\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.331\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6515597, step = 2600 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6515597, step = 2600 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.273\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.273\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.624181, step = 2700 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.624181, step = 2700 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.702\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.702\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6336497, step = 2800 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6336497, step = 2800 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.699\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.699\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6461319, step = 2900 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6461319, step = 2900 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 2997...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 2997...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 2997 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 2997 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 2997...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 2997...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 263.351\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 263.351\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.62288356, step = 3000 (0.380 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.62288356, step = 3000 (0.380 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.221\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.221\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.60181016, step = 3100 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.60181016, step = 3100 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.11\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.11\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6264686, step = 3200 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6264686, step = 3200 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.472\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.472\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.62783706, step = 3300 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.62783706, step = 3300 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.381\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.381\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.60665864, step = 3400 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.60665864, step = 3400 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.71\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.71\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5893868, step = 3500 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5893868, step = 3500 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.599\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.599\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5861173, step = 3600 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5861173, step = 3600 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.622\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.622\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6099591, step = 3700 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6099591, step = 3700 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.929\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.929\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.584367, step = 3800 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.584367, step = 3800 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.057\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.057\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6247656, step = 3900 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.6247656, step = 3900 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 3996...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 3996...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 3996 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 3996 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 3996...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 3996...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 269.991\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 269.991\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5847034, step = 4000 (0.370 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5847034, step = 4000 (0.370 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.341\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.341\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5222454, step = 4100 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5222454, step = 4100 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 314.332\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 314.332\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.56544733, step = 4200 (0.318 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.56544733, step = 4200 (0.318 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.469\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.469\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.53401303, step = 4300 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.53401303, step = 4300 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.091\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.091\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.60616475, step = 4400 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.60616475, step = 4400 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.789\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.789\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.54850054, step = 4500 (0.317 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.54850054, step = 4500 (0.317 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.835\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.835\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.53415287, step = 4600 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.53415287, step = 4600 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.461\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.461\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.54532635, step = 4700 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.54532635, step = 4700 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 316.775\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 316.775\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5452667, step = 4800 (0.316 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5452667, step = 4800 (0.316 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.409\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.409\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.56141084, step = 4900 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.56141084, step = 4900 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 4995...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 4995...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 4995 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 4995 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 4995...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 4995...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 264.325\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 264.325\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.598468, step = 5000 (0.378 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.598468, step = 5000 (0.378 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.864\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.864\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5625479, step = 5100 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5625479, step = 5100 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.495\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.495\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49302268, step = 5200 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49302268, step = 5200 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.527\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.527\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.51065207, step = 5300 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.51065207, step = 5300 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.907\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.907\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5923898, step = 5400 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5923898, step = 5400 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.074\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.074\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.44801658, step = 5500 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.44801658, step = 5500 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.86\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.86\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5714735, step = 5600 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5714735, step = 5600 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 324.686\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 324.686\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49483287, step = 5700 (0.308 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49483287, step = 5700 (0.308 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.892\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.892\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5302022, step = 5800 (0.309 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5302022, step = 5800 (0.309 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.891\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.891\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4477318, step = 5900 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4477318, step = 5900 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 5994...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 5994...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 5994 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 5994 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 5994...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 5994...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 266.097\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 266.097\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49755582, step = 6000 (0.375 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49755582, step = 6000 (0.375 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.809\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.809\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5602785, step = 6100 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5602785, step = 6100 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.832\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.832\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.46766576, step = 6200 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.46766576, step = 6200 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.529\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.529\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.479039, step = 6300 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.479039, step = 6300 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.589\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.589\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4789363, step = 6400 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4789363, step = 6400 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.142\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.142\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4339312, step = 6500 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4339312, step = 6500 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.307\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.307\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4122218, step = 6600 (0.309 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4122218, step = 6600 (0.309 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.444\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.444\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.58461237, step = 6700 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.58461237, step = 6700 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.942\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.942\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.46419075, step = 6800 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.46419075, step = 6800 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.865\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.865\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.48298937, step = 6900 (0.317 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.48298937, step = 6900 (0.317 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 6993...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 6993...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 6993 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 6993 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 6993...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 6993...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 264.18\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 264.18\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4932116, step = 7000 (0.378 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4932116, step = 7000 (0.378 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.19\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.19\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.57564336, step = 7100 (0.317 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.57564336, step = 7100 (0.317 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.109\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.109\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.42633593, step = 7200 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.42633593, step = 7200 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.107\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.107\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4498137, step = 7300 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4498137, step = 7300 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.072\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.072\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.41283035, step = 7400 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.41283035, step = 7400 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.335\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.335\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.47458777, step = 7500 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.47458777, step = 7500 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.662\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 315.662\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4127903, step = 7600 (0.317 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4127903, step = 7600 (0.317 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.9\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.9\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5836978, step = 7700 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5836978, step = 7700 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.817\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.817\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5894636, step = 7800 (0.314 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5894636, step = 7800 (0.314 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.436\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.436\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.43484074, step = 7900 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.43484074, step = 7900 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 7992...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 7992...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 7992 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 7992 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 7992...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 7992...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 264.902\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 264.902\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.53013414, step = 8000 (0.377 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.53013414, step = 8000 (0.377 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.632\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.632\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.39077514, step = 8100 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.39077514, step = 8100 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.701\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.701\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.44069138, step = 8200 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.44069138, step = 8200 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.354\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 322.354\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.35172203, step = 8300 (0.310 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.35172203, step = 8300 (0.310 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.48\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.48\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.37784338, step = 8400 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.37784338, step = 8400 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.185\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.185\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.39416346, step = 8500 (0.311 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.39416346, step = 8500 (0.311 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.449\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.449\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.42731768, step = 8600 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.42731768, step = 8600 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.796\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.796\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.36891136, step = 8700 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.36891136, step = 8700 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.506\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.506\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49558666, step = 8800 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.49558666, step = 8800 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.586\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.586\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4283083, step = 8900 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4283083, step = 8900 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 8991...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 8991...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 8991 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 8991 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 8991...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 8991...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 269.172\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 269.172\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.41561213, step = 9000 (0.371 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.41561213, step = 9000 (0.371 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.226\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 317.226\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.46039987, step = 9100 (0.315 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.46039987, step = 9100 (0.315 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.959\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 319.959\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.34406197, step = 9200 (0.313 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.34406197, step = 9200 (0.313 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.31\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.31\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.36776826, step = 9300 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.36776826, step = 9300 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.691\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.691\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.52139133, step = 9400 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.52139133, step = 9400 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.207\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 323.207\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.341009, step = 9500 (0.309 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.341009, step = 9500 (0.309 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.675\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 320.675\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.37580222, step = 9600 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.37580222, step = 9600 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.02\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 321.02\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5177429, step = 9700 (0.312 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.5177429, step = 9700 (0.312 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.166\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.166\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4260589, step = 9800 (0.314 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4260589, step = 9800 (0.314 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.877\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:global_step/sec: 318.877\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4696393, step = 9900 (0.314 sec)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:loss = 0.4696393, step = 9900 (0.314 sec)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 9990...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 9990...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 9990 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 9990 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 9990...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 9990...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 10000...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 10000...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 10000 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving checkpoints for 10000 into /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 10000...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling checkpoint listeners after saving checkpoint 10000...\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Skip the current checkpoint eval due to throttle secs (600 secs).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Starting evaluation at 2024-08-02T09:11:22\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Starting evaluation at 2024-08-02T09:11:22\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Graph was finalized.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Graph was finalized.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running local_init_op.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Running local_init_op.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done running local_init_op.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done running local_init_op.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [1500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [2500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [3500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4500/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [4500/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [5000/5000]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Evaluation [5000/5000]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Inference Time : 5.72028s\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Inference Time : 5.72028s\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Finished evaluation at 2024-08-02-09:11:28\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Finished evaluation at 2024-08-02-09:11:28\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving dict for global step 10000: accuracy = 0.8002, global_step = 10000, loss = 0.4460651\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving dict for global step 10000: accuracy = 0.8002, global_step = 10000, loss = 0.4460651\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving 'checkpoint_path' summary for global step 10000: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Saving 'checkpoint_path' summary for global step 10000: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Performing the final export in the end of training.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Performing the final export in the end of training.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:273: build_parsing_serving_input_receiver_fn (from tensorflow_estimator.python.estimator.export.export) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/temp/docs/tutorials/tfx/imdb_trainer.py:273: build_parsing_serving_input_receiver_fn (from tensorflow_estimator.python.estimator.export.export) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/export/export.py:312: ServingInputReceiver.__new__ (from tensorflow_estimator.python.estimator.export.export) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/export/export.py:312: ServingInputReceiver.__new__ (from tensorflow_estimator.python.estimator.export.export) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:Loading a TF2 SavedModel but eager mode seems disabled.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:Loading a TF2 SavedModel but eager mode seems disabled.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:365: PredictOutput.__init__ (from tensorflow.python.saved_model.model_utils.export_output) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:365: PredictOutput.__init__ (from tensorflow.python.saved_model.model_utils.export_output) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/signature_def_utils_impl.py:225: build_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/signature_def_utils_impl.py:225: build_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:83: get_tensor_from_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:83: get_tensor_from_tensor_info (from tensorflow.python.saved_model.utils_impl) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"This API was designed for TensorFlow v1. See https://www.tensorflow.org/guide/migrate for instructions on how to migrate your code to TensorFlow v2.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Classify: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Classify: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Regress: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Regress: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Predict: ['serving_default']\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Predict: ['serving_default']\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Train: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Train: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Eval: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Eval: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets added to graph.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets added to graph.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/export/imdb/temp-1722589888/assets\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/export/imdb/temp-1722589888/assets\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:SavedModel written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/export/imdb/temp-1722589888/saved_model.pb\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:SavedModel written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/export/imdb/temp-1722589888/saved_model.pb\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Loss for final step: 0.5098693.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Loss for final step: 0.5098693.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:Loading a TF2 SavedModel but eager mode seems disabled.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:Loading a TF2 SavedModel but eager mode seems disabled.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:struct2tensor is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_decision_forests is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:tensorflow_text is not available.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Done calling model_fn.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:345: _SupervisedOutput.__init__ (from tensorflow.python.saved_model.model_utils.export_output) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /tmpfs/src/tf_docs_env/lib/python3.9/site-packages/tensorflow/python/saved_model/model_utils/export_utils.py:345: _SupervisedOutput.__init__ (from tensorflow.python.saved_model.model_utils.export_output) is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Use tf.keras instead.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Classify: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Classify: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Regress: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Regress: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Predict: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Predict: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Train: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Train: None\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Eval: ['eval']\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Signatures INCLUDED in export for Eval: ['eval']\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"WARNING:tensorflow:Export includes no default signature!\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:tensorflow:Export includes no default signature!\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Restoring parameters from /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-Serving/model.ckpt-10000\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets added to graph.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets added to graph.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-TFMA/temp-1722589889/assets\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-TFMA/temp-1722589889/assets\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:SavedModel written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-TFMA/temp-1722589889/saved_model.pb\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:SavedModel written to: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9/Format-TFMA/temp-1722589889/saved_model.pb\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:Support for estimator-based executor and model export will be deprecated soon. Please use export structure /serving_model_dir/saved_model.pb\"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:Support for estimator-based executor and model export will be deprecated soon. Please use export structure /eval_model_dir/saved_model.pb\"\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"ExecutionResult at 0x7f1391615a00
.execution_id | 9 |
.component | \n",
"\n",
"Trainer at 0x7f139160c310 .inputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f139160c580 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8) at 0x7f11a05f14c0 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
| ['transform_graph'] | \n",
"\n",
"Channel of type 'TransformGraph' (1 artifact) at 0x7f11fc207160 .type_name | TransformGraph | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'TransformGraph' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7) at 0x7f11fc207370 .type | <class 'tfx.types.standard_artifacts.TransformGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7 |
|
|
| ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
| .outputs | ['model'] | \n",
"\n",
"Channel of type 'Model' (1 artifact) at 0x7f1391506a00 .type_name | Model | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Model' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model/9) at 0x7f13915069d0 .type | <class 'tfx.types.standard_artifacts.Model'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model/9 |
|
|
| ['model_run'] | \n",
"\n",
"Channel of type 'ModelRun' (1 artifact) at 0x7f1391506a90 .type_name | ModelRun | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ModelRun' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9) at 0x7f1391506340 .type | <class 'tfx.types.standard_artifacts.ModelRun'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9 |
|
|
|
| .exec_properties | ['train_args'] | {\n",
" "num_steps": 10000\n",
"} | ['eval_args'] | {\n",
" "num_steps": 5000\n",
"} | ['module_file'] | None | ['run_fn'] | None | ['trainer_fn'] | None | ['custom_config'] | null | ['module_path'] | imdb_trainer@/tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/_wheels/tfx_user_code_Trainer-0.0+02c7b97b194ad02bcc21de6184519fc73d0572a63c6c5af25fcac6f33b1320f9-py3-none-any.whl |
|
|
.component.inputs | ['examples'] | \n",
"\n",
"Channel of type 'Examples' (1 artifact) at 0x7f139160c580 .type_name | Examples | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Examples' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8) at 0x7f11a05f14c0 .type | <class 'tfx.types.standard_artifacts.Examples'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/GraphAugmentation/augmented_examples/8 | .span | 0 | .split_names | ["eval", "train"] | .version | 0 |
|
|
| ['transform_graph'] | \n",
"\n",
"Channel of type 'TransformGraph' (1 artifact) at 0x7f11fc207160 .type_name | TransformGraph | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'TransformGraph' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7) at 0x7f11fc207370 .type | <class 'tfx.types.standard_artifacts.TransformGraph'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Transform/transform_graph/7 |
|
|
| ['schema'] | \n",
"\n",
"Channel of type 'Schema' (1 artifact) at 0x7f11fc07a280 .type_name | Schema | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Schema' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4) at 0x7f12502c1df0 .type | <class 'tfx.types.standard_artifacts.Schema'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/SchemaGen/schema/4 |
|
|
|
|
.component.outputs | ['model'] | \n",
"\n",
"Channel of type 'Model' (1 artifact) at 0x7f1391506a00 .type_name | Model | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'Model' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model/9) at 0x7f13915069d0 .type | <class 'tfx.types.standard_artifacts.Model'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model/9 |
|
|
| ['model_run'] | \n",
"\n",
"Channel of type 'ModelRun' (1 artifact) at 0x7f1391506a90 .type_name | ModelRun | ._artifacts | [0] | \n",
"\n",
"Artifact of type 'ModelRun' (uri: /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9) at 0x7f1391506340 .type | <class 'tfx.types.standard_artifacts.ModelRun'> | .uri | /tmpfs/tmp/tfx-interactive-2024-08-02T09_08_00.145456-zzsoiua3/Trainer/model_run/9 |
|
|
|
|
"
],
"text/plain": [
"ExecutionResult(\n",
" component_id: Trainer\n",
" execution_id: 9\n",
" outputs:\n",
" model: OutputChannel(artifact_type=Model, producer_component_id=Trainer, output_key=model, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False)\n",
" model_run: OutputChannel(artifact_type=ModelRun, producer_component_id=Trainer, output_key=model_run, additional_properties={}, additional_custom_properties={}, _input_trigger=None, _is_async=False))"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Uses user-provided Python function that implements a model using TensorFlow's\n",
"# Estimators API.\n",
"trainer = Trainer(\n",
" module_file=_trainer_module_file,\n",
" custom_executor_spec=executor_spec.ExecutorClassSpec(\n",
" trainer_executor.Executor),\n",
" transformed_examples=graph_augmentation.outputs['augmented_examples'],\n",
" schema=schema_gen.outputs['schema'],\n",
" transform_graph=transform.outputs['transform_graph'],\n",
" train_args=trainer_pb2.TrainArgs(num_steps=10000),\n",
" eval_args=trainer_pb2.EvalArgs(num_steps=5000))\n",
"context.run(trainer)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "pDiZvYbFb2ph"
},
"source": [
"Take a peek at the trained model which was exported from `Trainer`."
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:11:30.362005Z",
"iopub.status.busy": "2024-08-02T09:11:30.361694Z",
"iopub.status.idle": "2024-08-02T09:11:30.665587Z",
"shell.execute_reply": "2024-08-02T09:11:30.664859Z"
},
"id": "qDBZG9Oso-BD"
},
"outputs": [],
"source": [
"train_uri = trainer.outputs['model'].get()[0].uri\n",
"serving_model_path = os.path.join(train_uri, 'Format-Serving')\n",
"exported_model = tf.saved_model.load(serving_model_path)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"execution": {
"iopub.execute_input": "2024-08-02T09:11:30.669505Z",
"iopub.status.busy": "2024-08-02T09:11:30.669210Z",
"iopub.status.idle": "2024-08-02T09:11:30.673924Z",
"shell.execute_reply": "2024-08-02T09:11:30.673319Z"
},
"id": "KyT3ZVGCZWsj"
},
"outputs": [
{
"data": {
"text/plain": [
"[,\n",
" ,\n",
" ,\n",
" ,\n",
" ,\n",
" ,\n",
" ,\n",
" ,\n",
" ,\n",
" ,\n",
" '...']"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"exported_model.graph.get_operations()[:10] + [\"...\"]"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zIsspBf5GjKm"
},
"source": [
"Let's visualize the model's metrics using Tensorboard."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "rnKeqLmcGqHH"
},
"outputs": [],
"source": [
"#docs_infra: no_execute\n",
"\n",
"# Get the URI of the output artifact representing the training logs,\n",
"# which is a directory\n",
"model_run_dir = trainer.outputs['model_run'].get()[0].uri\n",
"\n",
"%load_ext tensorboard\n",
"%tensorboard --logdir {model_run_dir}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "LgZXZJBsGzHm"
},
"source": [
"## Model Serving\n",
"\n",
"Graph regularization only affects the training workflow by adding a regularization term to the loss function. As a result, the model evaluation and serving workflows remain unchanged. It is for the same reason that we've also omitted downstream TFX components that typically come after the *Trainer* component like the *Evaluator*, *Pusher*, etc."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "qOh5FjbWiP-b"
},
"source": [
"## Conclusion\n",
"\n",
"We have demonstrated the use of graph regularization using the Neural Structured\n",
"Learning (NSL) framework in a TFX pipeline even when the input does not contain\n",
"an explicit graph. We considered the task of sentiment classification of IMDB\n",
"movie reviews for which we synthesized a similarity graph based on review\n",
"embeddings. We encourage users to experiment further by using different\n",
"embeddings for graph construction, varying hyperparameters, changing the amount\n",
"of supervision, and by defining different model architectures."
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [
"24gYiJcWNlpA"
],
"name": "Neural_Structured_Learning.ipynb",
"private_outputs": true,
"provenance": [],
"toc_visible": true
},
"file_extension": ".py",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
},
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": 3
},
"nbformat": 4,
"nbformat_minor": 0
}