I found it hard to use simple tf operations when building tf.keras model. For a toy example, let's say I want to stack two tensors from previous layers into one, keras doesn't have a stack function but tf does, but in order to use it, I have to do something like:
t1 = ...
t1 = ...
t_stack = tf.keras.layers.Lambda(lambda x: tf.stack(x, axis=-1))([t1, t2])
I'm just using tf.stack
as a toy example, it could be any tf operations that keras doesn't have (such as tf.image.resize
, lots of tf.math
operations etc.).
I want to know if there is a easy way to use arbitrary tf operations in keras? What about using tf.keras.backend
operations? I recon it is probably better to keep every operation as a keras layer. Will using backend operations break that rule?