I don't know why this error keep coming when I run the code below
CNN.fit(X_train_vector, y_train, epochs=10)
My CNN code is this:
CNN = tf.keras.models.Sequential()
CNN.add(tf.keras.layers.Conv1D(120, kernel_size=3, padding='valid', activation='relu', input_shape = (21367, 9000)))
CNN.add(tf.keras.layers.MaxPooling1D(2))
CNN.add(tf.keras.layers.Dropout(0.2))
CNN.add(tf.keras.layers.Flatten())
CNN.add(tf.keras.layers.Dense(200, activation='relu'))
CNN.add(tf.keras.layers.Dense(20, activation='relu'))
CNN.add(tf.keras.layers.Dense(1, activation='softmax'))
My "X_train_vector" has a shape:
(21367, 9000)
My "y_train" has a shape:
(21367, 1)
The Error I am getting:
Epoch 1/10
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-108-895976bf38cd> in <module>()
----> 1 CNN.fit(X_train_vector, y_train, epochs=10)
1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
1145 except Exception as e: # pylint:disable=broad-except
1146 if hasattr(e, "ag_error_metadata"):
-> 1147 raise e.ag_error_metadata.to_exception(e)
1148 else:
1149 raise
ValueError: in user code:
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1021, in train_function *
return step_function(self, iterator)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1010, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1000, in run_step **
outputs = model.train_step(data)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 859, in train_step
y_pred = self(x, training=True)
File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/usr/local/lib/python3.7/dist-packages/keras/engine/input_spec.py", line 264, in assert_input_compatibility
raise ValueError(f'Input {input_index} of layer "{layer_name}" is '
ValueError: Input 0 of layer "sequential_13" is incompatible with the layer: expected shape=(None, 21367, 9000), found shape=(None, 9000)
I have tried several solutions, including changing my first line of CNN to this:
CNN.add(tf.keras.layers.Conv1D(120, kernel_size=3, padding='valid', activation='relu', input_shape = (9000)))
But running it says:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-109-dd8d734d0a9f> in <module>()
1 CNN = tf.keras.models.Sequential()
----> 2 CNN.add(tf.keras.layers.Conv1D(120, kernel_size=3, padding='valid', activation='relu', input_shape = (9000)))
3 CNN.add(tf.keras.layers.MaxPooling1D(2))
4 CNN.add(tf.keras.layers.Dropout(0.2))
5 CNN.add(tf.keras.layers.Flatten())
3 frames
/usr/local/lib/python3.7/dist-packages/keras/engine/base_layer.py in __init__(self, trainable, name, dtype, dynamic, **kwargs)
441 else:
442 batch_size = None
--> 443 batch_input_shape = (batch_size,) + tuple(kwargs['input_shape'])
444 self._batch_input_shape = batch_input_shape
445
TypeError: 'int' object is not iterable
Can anyone help me. I have been looking for the solution for two days, it should work the way I am trying. Is there a mistake I am making? Please let me know.
Thanks In Advance.
The input array should have the shape (None, shape_0, shape_1), where None represent the batch size, and (shape_0, shape_1) represents the shape of the feature. So, you should reshape your input array:
X_train_vector = X_train_vector.reshape(-1, 9000, 1)
And you don't really need to specify the batch size when building the model, so remove that and just use (9000, 1) as the input_shape. Try this:
CNN = tf.keras.models.Sequential()
CNN.add(tf.keras.layers.Conv1D(120, kernel_size=3, padding='valid', activation='relu', input_shape = (9000, 1)))
CNN.add(tf.keras.layers.MaxPooling1D(2))
CNN.add(tf.keras.layers.Dropout(0.2))
CNN.add(tf.keras.layers.Flatten())
CNN.add(tf.keras.layers.Dense(200, activation='relu'))
CNN.add(tf.keras.layers.Dense(20, activation='relu'))
CNN.add(tf.keras.layers.Dense(1, activation='softmax'))
And this should solve the problem the same error would not appear again.
Related
I'm very new to machine learning and Keras. I'm attempting predictive values on a time series with 9 input features and 1 output feature.
I have input data of shape:(5787, 9) --> 5787 data points, 9 features per sample
I have target data of shape:(5787,) --> 5787 target data points
My model looks like this and compiles just fine:
# Build Model
model = Sequential()
model.add(layers.Dense(units=(features * neuron_per_feature),
# input_shape=input_data.shape,
activation = 'relu',
name='dense1',
))
# First GRU Layer
# input shape should be form (batch, window_size, features)
model.add(layers.GRU(features * neuron_per_feature,
# input_shape=(5787, features * neuron_per_feature),
dropout=dropout,
return_sequences=True,
name='gru1',
))
model.add(layers.Dense(features * (neuron_per_feature / 2),
activation = 'relu',
name='dense2',
))
model.add(layers.GRU(features * 4,
# input_shape=(window_size * features, ),
dropout=dropout,
return_sequences=False,
name='gru2',
))
model.add(layers.Dense(1,
name='dense3',
))
# Configure Adam optimizer
opt = keras.optimizers.Adam(
learning_rate=learning_rate,
beta_1=0.9,
beta_2=0.98,
epsilon=1e-9)
# Compile Model
model.compile(optimizer=opt, loss='mse') # mse = mean squared error
# model.summary()
I try to train the model like this:
`# Fit network
history = model.fit(
x=input_data,
y=target_data,
validation_split=0.0,
batch_size=batch_size,
epochs=epochs,
verbose="auto",
# validation_data=(test_X, test_Y),
shuffle=False,
workers=2,
use_multiprocessing=True,
)`
However, I continually get errors when adding in the GRU layers:
`<ipython-input-62-76971a07670d> in <module>
1 # Fit network
----> 2 history = model.fit(
3 x=input_data,
4 y=target_data,
5 validation_split=0.0,
1 frames
/usr/local/lib/python3.8/dist-packages/keras/engine/training.py in tf__train_function(iterator)
13 try:
14 do_return = True
---> 15 retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
16 except:
17 do_return = False
ValueError: in user code:
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1051, in train_function *
return step_function(self, iterator)
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1040, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1030, in run_step **
outputs = model.train_step(data)
File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 889, in train_step
y_pred = self(x, training=True)
File "/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/usr/local/lib/python3.8/dist-packages/keras/engine/input_spec.py", line 214, in assert_input_compatibility
raise ValueError(f'Input {input_index} of layer "{layer_name}" '
ValueError: Exception encountered when calling layer "sequential_19" (type Sequential).
Input 0 of layer "gru1" is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 108)
Call arguments received by layer "sequential_19" (type Sequential):
• inputs=tf.Tensor(shape=(None, 9), dtype=float32)
• training=True
• mask=None`
Any help would be much appreciated!
I've tried disabling the GRU layers, and the model will run the fit training. But when I re-add the GRUs, it fails.
I'm trying to train a CNN on my own images. I've set class_mode to sparse, so I figured I would use SparseCategoricalCrossentropy. However, when I do this (or even CategoricalCrossentropy), I get this error about the elements not being of a supported type.
I've tried a few different loss functions with the same error persisting. I think there must be something wrong with the formatting of my data. I've attached my data_gen and NN code along with the full traceback.
train_datagen = ImageDataGenerator(
rescale=1./255,
width_shift_range=.05,
height_shift_range=.05,
zoom_range=0.05,
validation_split=0.3,
horizontal_flip=True,
vertical_flip=True,
fill_mode="constant",
cval=0)
test_datagen = ImageDataGenerator(
rescale=1./255)
#data augmentation
train_ds = train_datagen.flow_from_directory(
train_data_dir,
shuffle=True,
target_size=(img_width, img_height),
batch_size=batch_size,
class_mode='sparse',
subset='training');
cnn = Sequential()
cnn.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=(img_width,img_height,3)))
cnn.add(BatchNormalization())
cnn.add(Conv2D(32, kernel_size=(3, 3), activation='relu'))
cnn.add(BatchNormalization())
cnn.add(MaxPooling2D(pool_size=(2, 2)))
cnn.add(Dropout(0.2))
cnn.add(Conv2D(64, kernel_size=(3, 3), activation='relu'))
cnn.add(BatchNormalization())
cnn.add(Flatten())
cnn.add(Dense(64, activation='relu'))
cnn.add(Dense(22, activation='softmax'))
cnn.compile(loss=keras.losses.SparseCategoricalCrossentropy,
optimizer="Adam",
metrics=['accuracy'])
--------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [24], line 111
106 cnn.compile(loss=keras.losses.SparseCategoricalCrossentropy,
107 optimizer="Adam",
108 metrics=['accuracy'])
110 epochs=20
--> 111 history = cnn.fit(
112 train_ds,
113 validation_data=valid_ds,
114 steps_per_epoch=math.ceil(len(train_ds) / batch_size),
115 epochs=epochs)
117 plt.plot(history.history['loss'], label='train')
118 plt.plot(history.history['val_loss'], label='validation')
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\utils\traceback_utils.py:70, in filter_traceback.<locals>.error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.__traceback__)
68 # To get the full stack trace, call:
69 # `tf.debugging.disable_traceback_filtering()`
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
File ~\AppData\Local\Temp\__autograph_generated_fileswqeb6ya.py:15, in outer_factory.<locals>.inner_factory.<locals>.tf__train_function(iterator)
13 try:
14 do_return = True
---> 15 retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
16 except:
17 do_return = False
TypeError: in user code:
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\engine\training.py", line 1160, in train_function *
return step_function(self, iterator)
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\engine\training.py", line 1146, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\engine\training.py", line 1135, in run_step **
outputs = model.train_step(data)
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\engine\training.py", line 994, in train_step
loss = self.compute_loss(x, y, y_pred, sample_weight)
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\engine\training.py", line 1052, in compute_loss
return self.compiled_loss(
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\engine\compile_utils.py", line 265, in __call__
loss_value = loss_obj(y_t, y_p, sample_weight=sw)
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\losses.py", line 158, in __call__
return losses_utils.compute_weighted_loss(
File "C:\Users\maiaz\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\utils\losses_utils.py", line 328, in compute_weighted_loss
losses = tf.convert_to_tensor(losses)
TypeError: Failed to convert elements of <keras.losses.SparseCategoricalCrossentropy object at 0x0000017523557AC0> to Tensor. Consider casting elements to a supported type. See https://www.tensorflow.org/api_docs/python/tf/dtypes for supported TF dtypes.
I'm trying to compile and fit a model but, this error is occurring:
ValueError: Shapes (None, 10, 10, 10) and (None, 10) are incompatible
code:
from tensorflow.keras.layers import Conv2D
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=3, activation="relu", input_shape=(28, 28, 1)))
model.add(Conv2D(filters=32, kernel_size=3, activation="relu"))
model.add(Flatten())
model.add(Dense(128, activation="relu"))
model.add(Dense(10, activation="softmax"))
# Compile the model
model.compile(loss="categorical_crossentropy", metrics=["accuracy"], optimizer="adam")
# Fit the model
model.fit( x=X_train, y=y_train, batch_size=32, epochs=10, validation_split = 0.3)
Output:
Epoch 1/10
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-18-a118e2826a10> in <module>()
3
4 # Fit the model
----> 5 model.fit( x=X_train, y=y_train, batch_size=32, epochs=10, validation_split = 0.3)
1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
1145 except Exception as e: # pylint:disable=broad-except
1146 if hasattr(e, "ag_error_metadata"):
-> 1147 raise e.ag_error_metadata.to_exception(e)
1148 else:
1149 raise
ValueError: in user code:
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1021, in train_function *
return step_function(self, iterator)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1010, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1000, in run_step **
outputs = model.train_step(data)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 860, in train_step
loss = self.compute_loss(x, y, y_pred, sample_weight)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 919, in compute_loss
y, y_pred, sample_weight, regularization_losses=self.losses)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/compile_utils.py", line 201, in __call__
loss_value = loss_obj(y_t, y_p, sample_weight=sw)
File "/usr/local/lib/python3.7/dist-packages/keras/losses.py", line 141, in __call__
losses = call_fn(y_true, y_pred)
File "/usr/local/lib/python3.7/dist-packages/keras/losses.py", line 245, in call **
return ag_fn(y_true, y_pred, **self._fn_kwargs)
File "/usr/local/lib/python3.7/dist-packages/keras/losses.py", line 1790, in categorical_crossentropy
y_true, y_pred, from_logits=from_logits, axis=axis)
File "/usr/local/lib/python3.7/dist-packages/keras/backend.py", line 5083, in categorical_crossentropy
target.shape.assert_is_compatible_with(output.shape)
ValueError: Shapes (None, 10, 10, 10) and (None, 10) are incompatible
I'm using tensorflow 2.8.2
How can i put it to work ?
What am i doing wrong ?
edit :
the problem was that I ran this part of the program twice (dumb mistake):
from tensorflow.keras.utils import to_categorical
y_train = to_categorical(y_train, num_classes=10)
y_test = to_categorical(y_test, num_classes=10)
print("Shape of y_train:", y_train.shape)
print("One value of y_train:", y_train[0])
I restarted the environment, and the problem was fixed.
I am creating a model to detect skin cancer using the ISIC skin cancer dataset. I have created a CNN model but after compiling it's throwing a shape error.
My-Code-
scale = 1./255
num_classes = 9
model = Sequential()
model.add(layers.experimental.preprocessing.Rescaling(scale, offset =0.0))
model.add(layers.Conv2D(32, (3, 3), padding = 'same', input_shape=(180, 180, 3)))
model.add(layers.Activation('relu'))
model.add(layers.Conv2D(64, (3, 3), padding='same'))
model.add(layers.Activation('relu'))
model.add(layers.Conv2D(128, (3, 3)))
model.add(layers.Activation('relu'))
model.add(layers.Flatten())
model.add(layers.Dense(20))
model.add(layers.Activation('relu'))
model.add(layers.Dense(num_classes))
model.add(layers.Activation('softmax'))
model.compile(optimizer='sgd',
loss='categorical_crossentropy',
metrics=['accuracy'])
epochs = 2
history = model.fit(
train_ds,
validation_data=val_ds,
epochs=epochs
)
My training data-
<PrefetchDataset shapes: ((None, 180, 180, 3), (None,)), types: (tf.float32, tf.int32)>
My Val data -
<PrefetchDataset shapes: ((None, 180, 180, 3), (None,)), types: (tf.float32, tf.int32)>
Now after fitting the model I am getting the error - ValueError: Shapes (None, 1) and (None, 9) are incompatible
Epoch 1/2
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-c695c39c566b> in <module>()
3 train_ds,
4 validation_data=val_ds,
----> 5 epochs=epochs
6 )
9 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
984 except Exception as e: # pylint:disable=broad-except
985 if hasattr(e, "ag_error_metadata"):
--> 986 raise e.ag_error_metadata.to_exception(e)
987 else:
988 raise
ValueError: in user code:
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:855 train_function *
return step_function(self, iterator)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:845 step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:1285 run
return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:2833 call_for_each_replica
return self._call_for_each_replica(fn, args, kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:3608 _call_for_each_replica
return fn(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:838 run_step **
outputs = model.train_step(data)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:797 train_step
y, y_pred, sample_weight, regularization_losses=self.losses)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/compile_utils.py:204 __call__
loss_value = loss_obj(y_t, y_p, sample_weight=sw)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/losses.py:155 __call__
losses = call_fn(y_true, y_pred)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/losses.py:259 call **
return ag_fn(y_true, y_pred, **self._fn_kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/dispatch.py:206 wrapper
return target(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/losses.py:1644 categorical_crossentropy
y_true, y_pred, from_logits=from_logits)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/dispatch.py:206 wrapper
return target(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/backend.py:4862 categorical_crossentropy
target.shape.assert_is_compatible_with(output.shape)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/tensor_shape.py:1161 assert_is_compatible_with
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (None, 1) and (None, 9) are incompatible
My Notebook
Data
You set label_mode='int', that's why you should use sparse_categorical_crossentropy as a loss function but you use loss function categorical_crossentropy which use generally when your target is one-hot encoded.
From tf.keras.preprocessing.image_dataset_from_directory, the label_mode should be as follows
- 'int': means that the labels are encoded as integers (e.g. for
sparse_categorical_crossentropy loss).
- 'categorical' means that the labels are encoded as a categorical
vector (e.g. for categorical_crossentropy loss).
- 'binary' means that the labels (there can be only 2) are encoded as
float32 scalars with values 0 or 1 (e.g. for binary_crossentropy).
- None (no labels).
That's why in your case, changing the loss function from categorical_crossentropy to sparse_categorical_crossentropy should solve the issue.
I have a working model, and I wish to begin using validation_split(=~0.1) to do my validation 'on the fly'. When I pass a validation_split other than 0.0, I get an error.
I have been tweaking the batch_size value that I pass to fit() as well as the one I pass to tf.keras.layers.Conv2D(), essentially making it proportional. No joy.
Here be how I make my model:
def make_convnet_model(flags, shape):
model = tf.keras.models.Sequential(
[
tf.keras.layers.Conv2D(32,(8,8), strides=2, activation='relu',input_shape=shape,batch_size=flags.batch_size,name='conv2d_1'),
tf.keras.layers.Conv2D(24, (4,4), strides=1, activation='relu',name='conv2d_2'),
tf.keras.layers.MaxPool2D(),
tf.keras.layers.Conv2D(16, (3, 3), strides=2, activation='sigmoid', input_shape=shape,batch_size=flags.batch_size, name='conv2d_3'),
tf.keras.layers.Conv2D(8, (3, 3), strides=1, activation='sigmoid', name='conv2d_4'),
tf.keras.layers.MaxPool2D(),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(64, activation='sigmoid', name='d3'),
tf.keras.layers.Dense(5, activation='softmax', name='softmax_d4')
])
return model
Here is how I call fit():
history = model.fit(x=X, y=Y, batch_size=flags.batch_size, epochs=flags.epochs, callbacks=[tensorboard,logger], verbose=flags.verbosity, validation_split=flags.validation_split)
Here is my reward. I have taken out some of the spooge:
Namespace(***batch_size=20***, columns=320, csv_path='../csv/', data_path='f:/downloads/aptos2019-blindness-detection/', epochs=2,
gray=False, learning_rate=0.001, loss='mean_squared_error',
metric=['accuracy'], model='conv2d', rows=320,
test_path_fragment='test_images/',
train_path_fragment='train_images/', validation_split=0.1,
verbosity=2)
Tensorflow version:1.14.0
Processed data path:f:/downloads/aptos2019-blindness-detection/train_images/color_320x320/
***Train on 18 samples, validate on 2 samples***
Epoch 1/2
Traceback (most recent call last):
File "F:/projects/retinas/retina.py", line 212, in <module>
main(sys.argv)
File "F:/projects/retinas/retina.py", line 122, in main
history = model.fit(x=X, y=Y, batch_size=flags.batch_size, epochs=flags.epochs, callbacks=[tensorboard,logger],
verbose=flags.verbosity, validation_split=flags.validation_split)
File "C:\Users\WascallyWabbit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\keras\engine\training.py",
line 780, in fit
steps_name='steps_per_epoch')
File "C:\Users\WascallyWabbit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py",
line 363, in model_iteration
batch_outs = f(ins_batch)
File "C:\Users\WascallyWabbit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\keras\backend.py",
line 3292, in call
run_metadata=self.run_metadata)
File "C:\Users\WascallyWabbit\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\client\session.py",
line 1458, in call
run_metadata_ptr)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [20,5] vs. [18,5]
[[{{node Adam/gradients/loss/softmax_d4_loss/SquaredDifference_grad/BroadcastGradientArgs}}]]
The problem turns out to have stemmed from unnecessarily specifying a batch_size in my call to Conv2D(). I now accept the default for that parameter, and it is working.
Not sure why. Don't really care :-|