Hardik Gupta
Hardik Gupta

Reputation: 1

How to change data type of a graph operation in tensorflow?

I am trying to build a decoder which requires Conv2DTranspose , but tensorflow iOS does not have operation MUL for int32 types. Is there a way I can change the data type of the input to MUL in my protobuf file or in keras saved model?

Upvotes: 0

Views: 2945

Answers (1)

Daniel Möller
Daniel Möller

Reputation: 86600

In the creation of the model:

  • Use K.cast(tensor, K.floatx())
  • Or tf.cast(tensor, tf.float32)

If the model is already created, replicate it, adding the operation at the right place (when in Keras, use a Lambda layer for that: Lambda(lambda x: K.cast(x,K.floatx()))), and transfer its weights (newModel.set_weights(oldModel.get_weights())).

Upvotes: 4

Related Questions