目录结构
{
"configuration": {
"target": {
"type": "image-classification",
"data_set": {
"type": "coco",
"source": "custom",
"split": "val"
},
"model_type": "resnet5",
"device": {
"name": "cpu",
"num_gpus": 1
},
"train": {
"learning_rate": 0.1,
"train_steps": 1,
"batch_size": 256,
"val_data": {
"validation": {
"ratio": 0.1
}
}
}
},
"data": {
"source": {
"path": "/path/to/data"
},
"preprocessing": {
"mean": [.485, 0.456, 0.379],
"std": [.224, 0.224, 0.224]
}
},
"model": {
"name": "resnet5",
"model_params": {
"depth": 5,
"num_classes": 1,
"weights": None
},
"迁移学习参数": {
"source_model": "resnet5",
"source_root_dir": "/path/to/saved-models"
}
},
"device": {
"name": "cpu",
"num_gpus": 1
},
"log": {
"file_path": "/path/to/logs",
"save频率": 1,
"save_path": "/path/to/logs/resnet5"
}
}
}
配置说明
目录结构
- configuration:整体配置文件,包含所有必要的设置。
- target:训练目标设置。
type:训练的目标类型(如image-classification、text-classification)。data_set:数据集类型和来源(如coco、mnist)。model_type:使用的模型类型(如resnet5、lstm)。device:使用的硬件平台和显卡数量。train:训练参数,包括学习率、训练轮数、批量大小等。
数据配置
- data:数据集来源和预处理参数。
source:数据集的来源路径。preprocessing:数据预处理参数,如均值、标准差等。
模型配置
- model:模型名称和参数设置。
name:模型名称(如resnet5、lstm)。model_params:模型参数,如层数、层数比例、激活函数等。迁移学习参数:迁移学习的参数设置,如源模型类型、源模型路径等。
设备配置
- device:硬件设备的配置。
name:使用的硬件平台(如cpu、gpu)。num_gpus:使用的显卡数量。
日志配置
- log:日志设置。
file_path:日志文件路径。save频率:日志保存频率(如1为每秒保存一次)。save_path:日志保存路径。
常用调整建议
- 学习率:调整为
.1或.2。 - 训练轮数:根据数据集和模型复杂度调整,如
5或6轮。 - 批量大小:
128或256。 - 验证数据比例:
.1或.2。 - 优化器:选择
AdamW或SGD。 - 梯度裁剪:
.1。 - 验证频率:
一次或一次/周期。
示例配置
{
"configuration": {
"target": {
"type": "image-classification",
"data_set": {
"type": "coco",
"source": "custom",
"split": "val"
},
"model_type": "resnet5",
"device": {
"name": "cpu",
"num_gpus": 1
},
"train": {
"learning_rate": 0.1,
"train_steps": 5,
"batch_size": 256,
"val_data": {
"validation": {
"ratio": 0.1
}
}
}
},
"data": {
"source": {
"path": "/path/to/data"
},
"preprocessing": {
"mean": [.485, 0.456, 0.379],
"std": [.224, 0.224, 0.224]
}
},
"model": {
"name": "resnet5",
"model_params": {
"depth": 5,
"num_classes": 1,
"weights": None
},
"迁移学习参数": {
"source_model": "resnet5",
"source_root_dir": "/path/to/saved-models"
}
},
"device": {
"name": "cpu",
"num_gpus": 1
},
"log": {
"file_path": "/path/to/logs",
"save_frequency": 1,
"save_path": "/path/to/logs/resnet5"
}
}
}
注意事项
- 数据集:确保数据集的来源和预处理参数与目标设置一致。
- 模型参数:迁移学习时,正确指定源模型的路径和参数。
- 优化器和学习率:根据模型复杂度调整优化器和学习率。
- 验证频率:根据训练轮数和数据集大小调整验证频率。
通过以上配置,你可以为sing-box设置合适的训练参数和配置,使其在训练过程中高效、有效。




