无法挤压 dim[4],期望维度为 1,结果为 3

Can not squeeze dim[4], expected a dimension of 1, got 3

我正在处理模型以 3D 长方体为输入并重建 3D 长方体的项目。我收到错误:

ValueError: Can not squeeze dim[4], expected a dimension of 1, got 3 for '{{node Squeeze}} = 
Squeeze[T=DT_FLOAT, squeeze_dims=[-1]](remove_squeezable_dimensions/Squeeze)' with input  
shapes: [1,227,227,10,3].

我正在使用以下型号。输入为10个高宽为227*227的连续帧,三个通道(R,G,B)

model=Sequential()
model.add(Conv3D(filters=128,kernel_size=(11,11,1),strides=(4,4,1),padding='valid',input_shape=(227,227,10,3),activation='tanh'))
model.add(Conv3D(filters=64,kernel_size=(5,5,1),strides=(2,2,1),padding='valid',activation='tanh'))
model.add(ConvLSTM2D(filters=64,kernel_size=(3,3),strides=1,padding='same',dropout=0.4,return_sequences=True,recurrent_dropout=0.3))
model.add(ConvLSTM2D(filters=32,kernel_size=(3,3),strides=1,padding='same',dropout=0.3,return_sequences=True))
model.add(ConvLSTM2D(filters=64,kernel_size=(3,3),strides=1,padding='same',dropout=0.5,return_sequences=True))
model.add(Conv3DTranspose(filters=128,kernel_size=(5,5,1),strides=(2,2,1),padding='valid',activation='tanh'))
model.add(Conv3DTranspose(filters=3,kernel_size=(11,11,1),strides=(4,4,1),padding='valid',activation='tanh'))
model.compile(optimizer='adam',loss='mean_squared_error',metrics=['accuracy'])



Model: "sequential"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 conv3d (Conv3D)             (None, 55, 55, 10, 128)   46592     
                                                                 
 conv3d_1 (Conv3D)           (None, 26, 26, 10, 64)    204864    
                                                                 
 conv_lstm2d (ConvLSTM2D)    (None, 26, 26, 10, 64)    295168    
                                                                 
 conv_lstm2d_1 (ConvLSTM2D)  (None, 26, 26, 10, 32)    110720    
                                                                 
 conv_lstm2d_2 (ConvLSTM2D)  (None, 26, 26, 10, 64)    221440    
                                                                 
 conv3d_transpose (Conv3DTra  (None, 55, 55, 10, 128)  204928    
 nspose)                                                         
                                                                 
 conv3d_transpose_1 (Conv3DT  (None, 227, 227, 10, 3)  46467     
 ranspose)                                                       
                                                                 
=================================================================
Total params: 1,130,179
Trainable params: 1,130,179
Non-trainable params: 0
_________________________________________________________________

我正在使用此代码创建数据集并训练模型

training_data = []
target_data = []
training_data=np.load('/content/training.npy')
print(training_data.shape)  #(227, 227, 3, 14943)
frames=training_data.shape[3]
frames=frames-frames%10

training_data=training_data[:,:,:,:frames]
training_data=training_data.reshape(-1,227,227,10,3)
training_data=np.expand_dims(training_data,axis=5)
target_data=training_data.copy()

epochs=15
batch_size=1

callback_save = ModelCheckpoint("saved_model.h5", monitor="mean_squared_error", save_best_only=True)

callback_early_stopping = EarlyStopping(monitor='loss', patience=3)

history = model.fit(training_data,target_data, batch_size=batch_size, epochs=epochs, callbacks = [callback_save,callback_early_stopping])
model.save("saved_model.h5")

需要training_data=np.expand_dims(training_data,axis=5)吗?我认为这使得训练数据形状与输入形状不兼容。