I'm passing a numpy array of dtype
float32
as my model's x
, and a numpy array of dtype
float32
as my model's y
. Both arrays have the same number of elements:
print(f"truth shape: {train_truth_sample_array[0].shape}, count: {len(train_truth_sample_array)}")
# truth shape: (80000,), count: 100
print(f"downscaled shape: {train_downscaled_sample_array[0].shape}, count: {len(train_downscaled_sample_array)}")
# downscaled shape: (40000,), count: 100
model = Sequential([
Input(shape=train_downscaled_sample_array[0].shape),
Dense(units=1000),
])
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
print(model.summary())
EPOCHS = 100
history = model.fit(x=train_downscaled_sample_array,
y=train_truth_sample_array,
epochs=EPOCHS,
callbacks=tf.keras.callbacks.EarlyStopping(verbose=1, patience=2))
But I'm getting the following error:
Data cardinality is ambiguous:
x sizes: 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000, 40000
y sizes: 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000, 80000
Make sure all arrays contain the same number of samples.
Why is this? Both arrays have the same count of elements...
question from:
https://stackoverflow.com/questions/66051207/data-cardinality-is-ambiguous-make-sure-all-arrays-contain-the-same-number-of-s