当我有多个参数时,为什么Optuna CSV文件每个参数只显示一个项目?



为了使用Optuna优化我的网络,我在Python中创建了以下代码。

activations_1 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_2 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_3 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_4 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu'])
model = Sequential([
layers.Conv2D(filters=dict_params['num_filters_1'],
kernel_size=dict_params['kernel_size_1'],
activation=dict_params['activations_1'],
strides=dict_params['stride_num_1'],
input_shape=self.input_shape),
layers.BatchNormalization(),
layers.MaxPooling2D(2, 2),
layers.Conv2D(filters=dict_params['num_filters_2'],
kernel_size=dict_params['kernel_size_2'],
activation=dict_params['activations_2'],
strides=dict_params['stride_num_2']),

正如你所看到的,我做了多次激活试验而不是一次,因为我想看看当每一层有不同的激活函数时,模型是否产生了更好的结果。正如你所看到的,我对其他参数做了同样的处理。当我归还书房时,我的困惑开始了。bestparams对象:

{"num_filters": 32, "kernel_size": 4, "strides": 1, "activation": "selu", "num_dense_nodes": 64, "batch_size": 64}

试验的最佳参数只产生一个参数。它没有告诉我在哪里使用了参数,也没有显示我使用的其他3个激活函数(或其他参数)。是否有一种方法可以精确地显示我的模型使用的最佳设置以及在哪些层?(我知道保存最好的模型和模型摘要,但这对我没有太大帮助)

问题是您对所有激活使用了相同的参数名称。而不是:

activations_1 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_2 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_3 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_4 = trial.suggest_categorical('activation', ['relu', 'sigmoid', 'tanh', 'selu'])

试题:

activations_1 = trial.suggest_categorical('activation1', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_2 = trial.suggest_categorical('activation2', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_3 = trial.suggest_categorical('activation3', ['relu', 'sigmoid', 'tanh', 'selu']) 
activations_4 = trial.suggest_categorical('activation4', ['relu', 'sigmoid', 'tanh', 'selu'])

相关内容

  • 没有找到相关文章

最新更新