Maybe this code is stupid, but I'd wanted check whether it allows to make a model that only dot-product the inputs.
This is my code.
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
import tensorflow as tf
import numpy as np
x = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]).reshape(1, 10)
y = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).reshape(1, 10)
x1 = [x for j in range(30)]
x2 = [y for j in range(30)]
y1 = [np.array([55]).reshape(1, 1) for j in range(30)]
input1 = Input(shape=(10,))
input2 = Input(shape=(10,))
dotted = Dot(axes=(1))([input1, input2])
model = Model(inputs = [input1, input2], outputs = [dotted])
model.compile(optimizer='rmsprop', loss='sparse_categorical_crossentropy')
history = model.fit(x=[x1, x2], y=np.array(y1))
Well, this gave me a ValueError as below.
ValueError: Data cardinality is ambiguous:
x sizes: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
y sizes: 30
Make sure all arrays contain the same number of samples.
I want to know two things from here.
First : Will this model runs well if I fix this ValueError?
Second : How can I fix this ValueError?