Dear All
I try to perform a simple multiplication using the first element of the output layer. My code looks like the following:
from tensorflow.keras.layers import *
import tensorflow as tf
scale_, mean_ = 2., 4.
a = Input(shape=(128,128), name=‘Input_vec’)
m_num = Input(shape=(4,), name=‘Input_num’)
output = Lambda(lambda x: tf.multiply(x[0], x[1]))((a, m_num[1]))
But I get the following error: ValueError: Dimensions must be equal, but are 128 and 4 for '{{node lambda_18/Mul}} = Mul[T=DT_FLOAT](Placeholder, Placeholder_1)' with input shapes: [?,128,128], [4].
@mohammad_gharaee , The shape of a in your code snippet would be [None, 128, 128] and shape of m_num would be [None, 4].
IMO, I don’t think they are multiplication compatible. I mean you can still multiply by broadcasting as @Bhack mentioned above but it doesn’t make sense to me in this case.
Can you mention a specific use case that you are trying to achieve here. May be then someone can help.
thanks @ashutosh1919, @Bhack
I already checked the doc and I know about broadcasting.
Actually here is my idea. I try to get some some parameters from image and using them create a matrix for next layer. In the image below you may see my rough idea. So I want to multiply each set of params to image.