Issue
Suppose that after giving input to a 2d-CNN, as the output of ith layer I have an Output Shape: (None, 1, 3, 1)
. I also have another input with shape (None, 50, 27, 1)
and what I want to multiply each element of columns 1-9 with the first element of (None, 1, 3, 1), each element of columns 10-18 with the second element of (None, 1, 3, 1) and each element of columns 19-27 with the third element of (None, 1, 3, 1). To summarize, what I want to do is as follows:
Doing this using lists is not difficult however, I want to do this in my keras model. Therefore, the type of my inputs are 'keras.engine.keras_tensor.KerasTensor'. Do you have an idea about how to do that?
Solution
If your inputs are a
and b
,
c = tf.keras.layers.Lambda(
lambda x: tf.concat(
[a*b for a, b in zip(
tf.split(x[1], 3, axis=-2),
tf.split(x[0], 3, axis=-2)
)
], axis=-2
)
)([a,b])
Answered By - thushv89
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.