0

我试图跑model.fit。我有一个目标形状为 5486 行的数据(5486,3)。我注意到在运行时model.fit,它在 4489 个训练样本和 997 个验证样本上打印了 Running 并且它开始于

Epoch 1/32 5/4856 [>.............................] - ETA: 180s - loss: 0.3286 - accuracy: 0.5406............. 某物

第二天我尝试了另一个脚本,并在应用fit它打印的方法时

显示的第一个代码5/4489是`

input_txt = Input(shape=(100,), dtype='int32')
txt = Masking(mask_value=0)(input_txt)
txt =  Embedding(len(word_index) + 1, embedding_dim, weights=[embedding_matrix], input_length=max_seq_len, trainable=False)(txt)
txt = Conv1D(32, 5,trainable = False)(txt)
txt = Conv1D(60, 4,trainable = False)(txt)
txt = Conv1D(100, 3,trainable = False)(txt)
text_lstm = Bidirectional(LSTM(30,return_sequences=True,trainable= False))(txt)
text_lstm = Bidirectional(LSTM(30,return_sequences=True,trainable= False))(text_lstm)
text_lstm = Bidirectional(LSTM(30,return_sequences=False,trainable= False))(text_lstm)
lstm = Dense(512, activation='relu')(text_lstm)
lstm = Dropout(0.8)(lstm)

input_img = Input(shape=(224,224,3))
model = VGG16(weights='imagenet', include_top=False)
model.trainable = False
x = model(input_img)
flatten = Flatten()(x)
flatten = Dense(1024, activation='relu')(flatten)
flatten = Dense(512, activation='relu')(flatten)
flatten = Dropout(0.8)(flatten)
merged = concatenate([lstm,flatten], axis=1)
dense = Dense(1024, activation='relu')(merged)
dense = Dropout(0.6)(dense) 
dense = Dense(512, activation='relu')(dense)
dense = Dense(256, activation='relu')(dense)
dense = Dense(128, activation='relu')(dense)
dense = Dense(3, activation='softmax')(dense)
model = Model(inputs=(input_img,input_txt), outputs=dense)
model.compile(loss='categorical_crossentropy',optimizer=keras.optimizers.Adam(lr=2e-5),metrics=["accuracy"])
X_trn = [image_data,text_data]
y_trn = labels
model.fit(X_trn,y_trn,validation_split=0.2,epochs = 32, batch_size = 64)

`

Epoch 1/32 5/151 [>.............................] - ETA: 40s - loss: 0.0286 - accuracy: 0.5406.............

给出上述详细信息的代码是`

vgg = VGG19(weights='imagenet',include_top=False)
vgg.trainable = False
img_in = Input(shape=(224,224,3),dtype = 'int32')

img = vgg(img_in)
img = Flatten()(img)
img = Dense(1024,activation='sigmoid')(img)
img = Dense(512,activation='sigmoid')(img)
img = Dense(64,activation='relu')(img)
img = Dense(32,activation = 'relu')(img)
out = Dense(3,activation='softmax')(img)
model = Model(inputs = [img_in],outputs=out)
model.compile(loss='categorical_crossentropy',
              optimizer=Adam(lr=2e-5),
              # optimizer=optimizers.RMSprop(),
              metrics=["accuracy"]
model.fit(x=images_data[4856:],y= data_labels[4856:],validation_data=(images_data[:4856], data_labels[:4856]),batch_size =64, epochs=32)

`

我注意到数据从 4489 下降到 101。我尝试检查所有内容,但一无所获。有人请解释发生了什么。提前致谢

4

0 回答 0