我正在做一些有关使用keras从岩石图像预测声波速度的研究。但是我的模型损失非常大,例如5000或更多,acc为0,有时为负数。我怀疑我的网络层有问题,我的训练数据是数以百万计的岩石图像,这些图像通过其UUID和声波速度进行了标记。
我正在尝试更改损失函数,优化器并添加辍学以防止过度拟合,但是它也不起作用。
####################push images and soundwavespped into a array##############
model = Sequential()
model.add(Conv2D(filters=16,kernel_size=(2,2),padding='same',input_shape=(37,44,1)))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=-1))
model.add(MaxPooling2D(pool_size=(2,2),padding='same'))
model.add(Conv2D(filters=32,kernel_size=(2,2),padding='same'))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=-1))
model.add(MaxPooling2D(pool_size=(2,2),padding='same'))
model.add(Conv2D(filters=64,kernel_size=(2,2),padding='same'))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=-1))
model.add(MaxPooling2D(pool_size=(2,2),padding='same'))
model.add(Flatten())
model.add(Dense(1024))
model.add(Activation("relu"))
model.add(Dropout(0.5))
# model.add(Dense(64))
# model.add(Activation("relu"))
model.add(Dense(1,activation="linear"))
adam= Adam(lr=1e-3, decay=1e-3 / 1)
model.compile(loss='mean_absolute_percentage_error',optimizer=adam, metrics=['accuracy'])
history=model.fit(trainsetImage, trainsetSpeed, batch_size=32,validation_data=(testsetImage, testsetSpeed), epochs=1,shuffle=True)
model.save(os.path.join(rootdir, 'model_weight.h5'))
loss,accuracy = model.evaluate(testsetImage,testsetSpeed)
photos of rocks named by combination of id and soundwave speed