Resistor Ohm Value Estimation Challenge
需要将误差降低到1%以下
1、调整模型架构:增加模型的复杂性,例如增加卷积层或全连接层的数量,增加神经元数量等
# 在 ResistorEstimator 类的 CNN 方法中进行修改
def CNN(self, type):
input = Input(shape=(64, 64, 3), name='input')
h = self.conv2d(input, 32, (3, 3), padding=True, activation='relu', id=1)
h = self.conv2d(h, 64, (3, 3), padding=True, activation='relu', id=2)
# 添加更多卷积层...
h = GlobalAveragePooling2D()(h)
h = Dense(256, activation='relu', name='dense_1')(h)
if type == 'cls':
output = Dense(14, activation='softmax', name='output')
elif type == 'reg':
output = Dense(1, activation='linear', name='output')
return Model(inputs=input, outputs=output)
2、学习率调整
model.cnn.compile(optimizer=Adam(learning_rate=0.0001), loss='huber_loss', metrics='mae')
3、数据增强:调参
generator = ImageDataGenerator(
rotation_range=45,
width_shift_range=0.1,
height_shift_range=0.1,
zoom_range=[0.9, 1.1],
horizontal_flip=True,
vertical_flip=False,
fill_mode='nearest'
)
4、增加训练时长:增加epochs的值
history = model.cnn.fit(train_ds, epochs=200, callbacks=[tb_cb], validation_data=valid_ds)
目前还在苦逼调参中。。