Many thanks for your kind reply. I did the following trail but still receiving an error as you see below, Where shall I add a layer in order to make the dimension match the following layer. any solution!
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
# Setup input shape and base model, freezing the base model layers
input_shape = (256, 256, 3)
base_model = create(classes_num=1000, image_height=299, image_width=299, image_channel=3)
base_model.trainable = False
# Create input layer
inputs = layers.Input(shape=input_shape, name="input_layer")
# Add in data augmentation Sequential model as a layer
# x = data_augmentation(inputs)
# Give base_model inputs (after augmentation) and don't train it
x = base_model(inputs, training=False)
# Pool output features of base model
x = layers.GlobalAveragePooling2D(name="global_average_pooling_layer")(x)
# Put a dense layer on as the output
outputs = layers.Dense(10, activation="softmax", name="output_layer")(x)
# Make a model with inputs and outputs
model_1 = keras.Model(inputs, outputs)
ValueError Traceback (most recent call last)
in <cell line: 18>()
16
17 # Give base_model inputs (after augmentation) and don’t train it
—> 18 x = base_model(inputs, training=False)
19
20 # # Pool output features of base model
1 frames
/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs, op_def, extract_traceback)
1971 except errors.InvalidArgumentError as e:
1972 # Convert to ValueError for backwards compatibility.
→ 1973 raise ValueError(e.message)
1974
1975 # Record the current Python stack trace as the creating stacktrace of this
ValueError: Exception encountered when calling layer ‘average_pooling2d_89’ (type AveragePooling2D).
Negative dimension size caused by subtracting 8 from 6 for ‘{{node Inception-v4/average_pooling2d_89/AvgPool}} = AvgPoolT=DT_FLOAT, data_format=“NHWC”, ksize=[1, 8, 8, 1], padding=“VALID”, strides=[1, 8, 8, 1]’ with input shapes: [?,6,6,1536].
Call arguments received by layer ‘average_pooling2d_89’ (type AveragePooling2D):
• inputs=tf.Tensor(shape=(None, 6, 6, 1536), dtype=float32)