вот мой cnn
и получаю
model = cnn_model () print (model.call (train_data [0])) ValueError: Ввод
0 уровня conv2d_6 несовместим с уровнем: ожидаемый ndim = 4,
найдено ndim = 3. Получена полная форма: [28, 28, 1]
и форма (28,28,1)
что не так?
input_shape = (28,28.1)
class cnn_model(tf.keras.Model):
def __init__(self):
super(cnn_model,self).__init__()
self.conv1 = layers.Conv2D(32,(3,3),activation='relu',input_shape= input_shape)
self.maxpool = layers.MaxPool2D((2,2))
self.conv2 = layers.Conv2D(64,(3,3),activation ='relu')
self.conv3 = layers.Conv2D(64,(3,3),activation='relu')
self.flatten = layers.Flatten()
self.dense64 = layers.Dense(64,activation='relu')
self.dense10 = layers.Dense(10,activation='relu')
def call(self,inputs):
x = self.conv1(inputs)
x = self.maxpool(x)
x = self.conv2(x)
x = self.maxpool(x)
x = self.conv3(x)
x = self.flatten(x)
x = self.dense64(x)
x = self.dense10(x)
return x