forefinger
forefinger

Reputation: 3867

Weird tf.Print bug

I am trying to use a tf.Print like this:

residual = tf.Print(residual, [residual], message='enc', summarize=100)

but it crashes with this error:

ValueError: Single tensor passed to 'data', expected list while building NodeDef 'tf_op_layer_tf_op_layer_TransformerEncoder/TransformerEncoderBlock/Print/TransformerEncoder/TransformerEncoderBlock/Print' using Op<name=Print; signature=input:T, data: -> output:T; attr=T:type; attr=U:list(type),min=0; attr=message:string,default=""; attr=first_n:int,default=-1; attr=summarize:int,default=3; is_stateful=true>

This makes no sense to me because the data argument is wrapped in a list.

Upvotes: 2

Views: 135

Answers (1)

forefinger
forefinger

Reputation: 3867

Found answer here:

https://epcsirmaz.blogspot.com/2018/06/display-full-value-of-tensor-in.html

Basically, when using Keras, you have to wrap it in a lambda layer.

Upvotes: 2

Related Questions