问题描述
我使用的是多模态 MR 图像数据集。我不明白是什么导致了训练期间出现此错误:
InvalidArgumentError: logits and labels must have the same first dimension,got logits shape [64,4] and labels shape [9437184]
sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits
我的代码:
conv_base=VGG16(weights='imagenet',include_top=False,input_shape=(192,192,3))
model.add(conv_base)
model.add(layers.Flatten())
model.add(layers.Dense(512,activation='relu'))
model.add(layers.Dropout(0.5))
model.add(layers.Dense(4,activation= 'softmax'))
model.compile(optimizer=optimizers.Adam(lr=3e-5),loss='sparse_categorical_crossentropy',metrics=['acc'])
h=model.fit(X_train,Y_train,batch_size=64,epochs=1,verbose=1,validation_data=(X_val,Y_val))
X_train
的形状是 (162,3)
。
Y_train
的形状是 (162,4)
。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)