How to add Input Parameter in T2T using Tensorflow Serving

64 views
Skip to first unread message

Simon Mc Duff

unread,
Jul 19, 2018, 2:30:32 PM7/19/18
to tensor2tensor
Hi,

I'm trying to add a new parameters to t2t.

new parameter name : newparam type=int64.

I added the following to the problem

def example_reading_spec(self):
 [...]
    data_fields["newparam"] = tf.VarLenFeature(tf.int64)

After that in my transformer I did the following:

newparam=tf.placeholder(tf.int64,name="newparam")



I'm able to export my model but I have an error when I query it.
For the query, I add it in the input variables at the same level than the t2t inputs.

INVALID_ARGUMENT: You must feed a value for placeholder tensor 'transformer/while/newparam' with dtype int64

Do I need to do something else ?

I'm using Tensor2tensor 1.6.5

Thank you

Simon

Ryan Sepassi

unread,
Jul 19, 2018, 2:35:50 PM7/19/18
to Simon Mc Duff, tensor2tensor
there should be no need for the placeholder.
if you added the feature to the example_reading_spec, it should now be in the features dictionary in the model

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tenso...@googlegroups.com.
To post to this group, send email to tensor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tensor2tensor/e2055e56-970d-48d3-82d2-b7d24e82b722%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Mc Duff

unread,
Jul 19, 2018, 7:07:48 PM7/19/18
to Ryan Sepassi, tensor2tensor
Thank you Ryan!


Now I can go further... but still have weird error.

When I send one prediction (t2t) with my parameters, I have 2 responses ??

The first one is correct, but the other one is garbage...

When I created the protobuf to create my parameters.
I have a list which contains 
- a feature with name "inputs"
- a feature with name "newparam"

It seems that tensorflow serving believe it is 2 inputs.... somehow. And my parameters doesn`t seems to be used at all.


def example_reading_spec(self):
 [...]
    data_fields["newparam"] = tf.VarLenFeature(tf.int64)



 newparam  =  features["newparam"]
 newparam  = newparam[0,:]                            # what represents the first dimension ?? I took the second dimension believing this is what I need.



      
Simon


2018-07-19 14:35 GMT-04:00 Ryan Sepassi <rsep...@google.com>:
there should be no need for the placeholder.
if you added the feature to the example_reading_spec, it should now be in the features dictionary in the model

On Thu, Jul 19, 2018 at 11:30 AM Simon Mc Duff <simon....@gmail.com> wrote:
Hi,

I'm trying to add a new parameters to t2t.

new parameter name : newparam type=int64.

I added the following to the problem

def example_reading_spec(self):
 [...]
    data_fields["newparam"] = tf.VarLenFeature(tf.int64)

After that in my transformer I did the following:

newparam=tf.placeholder(tf.int64,name="newparam")



I'm able to export my model but I have an error when I query it.
For the query, I add it in the input variables at the same level than the t2t inputs.

INVALID_ARGUMENT: You must feed a value for placeholder tensor 'transformer/while/newparam' with dtype int64

Do I need to do something else ?

I'm using Tensor2tensor 1.6.5

Thank you

Simon

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tensor+unsubscribe@googlegroups.com.

Ryan Sepassi

unread,
Jul 19, 2018, 8:01:36 PM7/19/18
to Simon Mc Duff, tensor2tensor
the thing you send to serving should be a tensorflow.Example proto that's going to go through the same parsing as happens during training so make sure the structure is the same

To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tenso...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tensor2tensor/e2055e56-970d-48d3-82d2-b7d24e82b722%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tenso...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.

Simon Mc Duff

unread,
Jul 19, 2018, 8:05:00 PM7/19/18
to Ryan Sepassi, tensor2tensor
This is what I do already...

For inputs
    org.tensorflow.example.Int64List.Builder addAllValue = org.tensorflow.example.Int64List.newBuilder()
        .addAllValue(encode);
    Feature build = Feature.newBuilder().setInt64List(addAllValue).build();
    Features build2 = Features.newBuilder().putFeature(INPUTS, build).build();
    org.tensorflow.example.Example.Builder exampleBuilder = Example.newBuilder().setFeatures(build2);

For newParam
    org.tensorflow.example.Int64List.Builder addAllValue = org.tensorflow.example.Int64List.newBuilder()
        .addAllValue(encode);
    Feature build = Feature.newBuilder().setInt64List(addAllValue).build();
    Features build2 = Features.newBuilder().putFeature("newparam", build).build();
    org.tensorflow.example.Example.Builder exampleBuilder = Example.newBuilder().setFeatures(build2);


To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tensor+unsubscribe@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tensor2tensor/e2055e56-970d-48d3-82d2-b7d24e82b722%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tensor+unsubscribe@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.

Ryan Sepassi

unread,
Jul 19, 2018, 8:18:00 PM7/19/18
to Simon Mc Duff, tensor2tensor
it looks to me like you're creating 2 Example protos. you should be creating just 1 that contains the 2 features

To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tenso...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tensor2tensor/e2055e56-970d-48d3-82d2-b7d24e82b722%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tenso...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tenso...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.

Simon Mc Duff

unread,
Jul 19, 2018, 8:34:19 PM7/19/18
to Ryan Sepassi, tensor2tensor
IT IS WORKING!!! :-)

This was the problem! Thank you so much! 

Simon

To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tensor+unsubscribe@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tensor2tensor/e2055e56-970d-48d3-82d2-b7d24e82b722%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tensor+unsubscribe@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor2tensor+unsubscribe@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.

Erik Chan

unread,
Oct 3, 2019, 11:33:00 AM10/3/19
to tensor2tensor
Hi Simon

Would you mind sharing your code? I am also trying to do Input Parameter in T2T using Tensorflow Serving and am having trouble with this.

Thanks!
Erik



El viernes, 20 de julio de 2018, 8:34:19 (UTC+8), Simon Mc Duff escribió:
IT IS WORKING!!! :-)

This was the problem! Thank you so much! 

Simon
2018-07-19 20:17 GMT-04:00 Ryan Sepassi <rsep...@google.com>:
it looks to me like you're creating 2 Example protos. you should be creating just 1 that contains the 2 features

To unsubscribe from this group and stop receiving emails from it, send an email to tensor...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tensor2tensor/e2055e56-970d-48d3-82d2-b7d24e82b722%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tensor...@googlegroups.com.

To post to this group, send email to tensor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages