How to pass key to Tensorflow graph

louis030195
2 min readSep 5, 2019

When you are using Google Cloud AI Platform batch prediction, launching a job takes an input path (where multiple inputs are placed) and an output path (where it will put the result in files).

The problem is that you can’t link the output result to its input, so I needed to pass the key in input to the model and each result will have the key allowing to find back which input it was.

I couldn't find a solution on the internet myself so I had to implement it modifying Tensorflow Models tools, I hope it will help people that was in the same case than me.

Tensorflow Models tool to export models

My modified version of their tool to add a key to both input and output

Differences with original

How to use it:

Initial model graph
Modified graph, notice the input_keys and output_keys

Additionally, I have built a notebook to download, edit and deploy a model to AI Platform with Google Colab

UPDATE: i’ve built a Cloud Run component that does the work here

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

louis030195
louis030195

Written by louis030195

Chief Executive. Bookworm. AI Engineer. I write about code, AI, OSS, PKM, business, and books

No responses yet

Write a response