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].
1 Like
@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.
1 Like
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.
I really appreciate your help.
2 Likes
@mohammad_gharaee , I think you forgot to attach the image.
1 Like
I tried to do so but I got the error “Sorry, you can’t embed media items in a post.”
1 Like
@ashutosh1919
Here is the image. Just replace - with .
drive-google-com/file/d/1U6oEAuTGscujR6HGtlpe976ssjZZr14q/view?usp=sharing
1 Like