请问老师,这个平滑数据在tensorboard中我手工调节平滑或者毛刺多一些,但是比如我调整平滑了,在代码中怎么修改一下吗需要,这个对应什么参数吗,我是tf下的keras实现的。部分代码我贴一下啊
def build_model(shape, num_classes=5):
’’’
:param shape: 一条样本维度或样本预处理后的特征数目
:param num_classes: 类别数
:return: 模型对象,用于训练
’’'
model = Sequential()
model.add(Dense(128, input_dim=shape, init=‘uniform’, activation=‘relu’))
# 添加全连接层,单元数64,激活函数为ReLU
model.add(Dense(64, init=‘uniform’, activation=‘relu’))
# 添加随机失活层
model.add(Dropout(0.5))
# 添加全连接层,单元数32,激活函数为ReLU
model.add(Dense(32, activation=‘relu’))
# 添加全连接层,单元数16,激活函数为ReLU
model.add(Dense(16, activation=‘relu’))
model.add(Dropout(0.5))
# 添加全连接层,单元数2,激活函数为sigmoid
model.add(Dense(num_classes, activation=‘softmax’))
return model
model_name = “DNN-64x2-{}”.format(int(time.time()))
tensorboard = TensorBoard(log_dir=‘logs/{}’.format(model_name))
model = build_model(x_train.shape[1])
sgd = optimizers.Adam(lr=0.0001)
model.compile(loss=‘categorical_crossentropy’, optimizer=sgd, metrics=[‘accuracy’])
history = model.fit(x_train, y_train, batch_size=120, epochs=300, callbacks=[tensorboard])
#保存模型
model.save(‘model.h5’)