I want to Conv2d two tensor.
However, it gives tensorflow.python.framework.errors_impl.NotFoundError: No algorithm worked! [Op:Conv2D]
Here is my code:
oneone = tf.random.uniform(shape=[1,1,10,3])
xx = tf.random.uniform([3,3,10,100])
kernel = kb.conv2d(xx, oneone, padding=‘same’)
It does work in pytorch:
torch.nn.functional.conv2d(weight_x_x_, weight_1_1_)
May I know what I missed?
Yes, please have a look at Functional API document for many examples on how to build models with multiple inputs.
Please refer to the sample code below, where you will probably want to pass the image through a convolution layer, flatten the output and concatenate it with vector input:
from tensorflow.keras.layers import Input, Concatenate, Conv2D, Flatten, Dense
from tensorflow.keras.models import Model
# Define two input layers
image_input = Input((32, 32, 3))
vector_input = Input((6,))
# Convolution + Flatten for the image
conv_layer = Conv2D(32, (3,3))(image_input)
flat_layer = Flatten()(conv_layer)
# Concatenate the convolutional features and the vector input
concat_layer= Concatenate()([vector_input, flat_layer])
output = Dense(3)(concat_layer)
# define a model with a list of two inputs
model = Model(inputs=[image_input, vector_input], outputs=output)
Thank you.