shuffle_seed: 0 # 数据打散的种子 干嘛用的

本文详细解析了深度学习训练过程中的关键配置参数,包括batch_size、num_workers等,以及训练集标签文件和图像数据路径的具体设定,对于理解深度学习模型训练流程及优化具有重要参考价值。

https://blog.youkuaiyun.com/u010589524/article/details/89371919

 

TRAIN: # 训练配置
    batch_size: 32 # 训练的batch size
    num_workers: 4 # 每个trainer(1块GPU上可以视为1个trainer)的进程数量
    file_list: "./dataset/flowers102/train_list.txt" # 训练集标签文件,每一行由"image_name label"组成
    data_dir: "./dataset/flowers102/" # 训练集的图像数据路径
    shuffle_seed: 0 # 数据打散的种子

通过设置全局随机种子使得每次的训练结果相同可以复现

 

https://aistudio.baidu.com/bdvgpu32g/user/2292/515777/notebooks/515777.ipynb?redirects=1

 

 

https://blog.youkuaiyun.com/linzch3/article/details/58220569?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase

解释这个文件。_target_: diffusion_policy.workspace.train_diffusion_unet_hybrid_workspace.TrainDiffusionUnetHybridWorkspace checkpoint: save_last_ckpt: true save_last_snapshot: false topk: format_str: epoch={epoch:04d}-test_mean_score={test_mean_score:.3f}.ckpt k: 5 mode: max monitor_key: test_mean_score dataloader: batch_size: 64 num_workers: 8 persistent_workers: false pin_memory: true shuffle: true dataset_obs_steps: 2 ema: _target_: diffusion_policy.model.diffusion.ema_model.EMAModel inv_gamma: 1.0 max_value: 0.9999 min_value: 0.0 power: 0.75 update_after_step: 0 exp_name: default horizon: 16 keypoint_visible_rate: 1.0 logging: group: null id: null mode: online name: 2023.01.16-20.20.06_train_diffusion_unet_hybrid_pusht_image project: diffusion_policy_debug resume: true tags: - train_diffusion_unet_hybrid - pusht_image - default multi_run: run_dir: data/outputs/2023.01.16/20.20.06_train_diffusion_unet_hybrid_pusht_image wandb_name_base: 2023.01.16-20.20.06_train_diffusion_unet_hybrid_pusht_image n_action_steps: 8 n_latency_steps: 0 n_obs_steps: 2 name: train_diffusion_unet_hybrid obs_as_global_cond: true optimizer: _target_: torch.optim.AdamW betas: - 0.95 - 0.999 eps: 1.0e-08 lr: 0.0001 weight_decay: 1.0e-06 past_action_visible: false policy: _target_: diffusion_policy.policy.diffusion_unet_hybrid_image_policy.DiffusionUnetHybridImagePolicy cond_predict_scale: true crop_shape: - 84 - 84 diffusion_step_embed_dim: 128 down_dims: - 512 - 1024 - 2048 eval_fixed_crop: true horizon: 16 kernel_size: 5 n_action_steps: 8 n_groups: 8 n_obs_steps: 2 noise_scheduler: _target_: diffusers.schedulers.scheduling_ddpm.DDPMScheduler beta_end: 0.02 beta_schedule: squaredcos_cap_v2 beta_start: 0.0001 clip_sample: true num_train_timesteps: 100 prediction_type: epsilon variance_type: fixed_small num_inference_steps: 100 obs_as_global_cond: true obs_encoder_group_norm: true shape_meta: action: shape: - 2 obs: agent_pos: shape: - 2 type: low_dim image: shape: - 3 - 96 - 96 type: rgb shape_meta: action: shape: - 2 obs: agent_pos: shape: - 2 type: low_dim image: shape: - 3 - 96 - 96 type: rgb task: dataset: _target_: diffusion_policy.dataset.pusht_image_dataset.PushTImageDataset horizon: 16 max_train_episodes: 90 pad_after: 7 pad_before: 1 seed: 42 val_ratio: 0.02 zarr_path: data/pusht/pusht_cchi_v7_replay.zarr env_runner: _target_: diffusion_policy.env_runner.pusht_image_runner.PushTImageRunner fps: 10 legacy_test: true max_steps: 300 n_action_steps: 8 n_envs: null n_obs_steps: 2 n_test: 50 n_test_vis: 4 n_train: 6 n_train_vis: 2 past_action: false test_start_seed: 100000 train_start_seed: 0 image_shape: - 3 - 96 - 96 name: pusht_image shape_meta: action: shape: - 2 obs: agent_pos: shape: - 2 type: low_dim image: shape: - 3 - 96 - 96 type: rgb task_name: pusht_image training: checkpoint_every: 50 debug: false device: cuda:0 gradient_accumulate_every: 1 lr_scheduler: cosine lr_warmup_steps: 500 max_train_steps: null max_val_steps: null num_epochs: 3050 resume: true rollout_every: 50 sample_every: 5 seed: 42 tqdm_interval_sec: 1.0 use_ema: true val_every: 1 val_dataloader: batch_size: 64 num_workers: 8 persistent_workers: false pin_memory: true shuffle: false
06-29
### 3.2 配置文件解析与作用说明 在 `diffusion_policy.workspace.train_diffusion_unet_hybrid_workspace` 的配置文件中,各个部分定义了训练扩散 UNet 混合模型所需的核心参数和模块结构。这些参数控制着数据加载、模型架构、优化器设置、训练流程以及日志记录等关键环节。 #### 数据加载与预处理 ```yaml dataset: _target_: diffusion_policy.dataset.pusht_image_dataset.PushtImageDataset zarr_path: data/pusht.zarr horizon: 16 pad_before: 8 pad_after: 8 seed: 42 ``` 该部分指定了使用的数据集类型及其路径。例如,在 PushT 任务中,使用的是 `PushtImageDataset` 类,输入的 `.zarr` 文件包含图像观测和动作序列。`horizon` 控制每段轨迹的时间步长,而 `pad_before` 和 `pad_after` 用于对齐时间轴以适配卷积操作[^2]。这一设计允许网络更好地捕捉时间连续性。 #### 模型结构定义 ```yaml model: _target_: diffusion_policy.model.diffusion_model.DiffusionUnetHybridModel obs_encoder: _target_: diffusion_policy.model.obs_encoders.CNNObsEncoder shape_meta: obs: image: shape: [3, 96, 96] noise_scheduler: _target_: diffusers.schedulers.DDPMScheduler num_train_timesteps: 1000 beta_schedule: "linear" loss_weight: action: 1.0 obs: 0.0 ``` `model` 部分定义了扩散 UNet 混合模型的核心结构。其中,`obs_encoder` 使用 CNN 对图像进行编码,输出低维特征向量;`noise_scheduler` 定义了去噪过程中的调度策略,通常采用 DDPMScheduler 或 DDIMScheduler;`loss_weight` 控制动作预测和状态重建损失之间的平衡[^2]。这种混合建模方式使得模型既能学习动作分布,又能保留观测空间的语义信息。 #### 优化器与训练参数 ```yaml training: batch_size: 64 lr: 1e-4 weight_decay: 1e-5 grad_clip_norm: 1.0 device: cuda:0 ema_rate: 0.999 ``` 这部分设置了优化器的基本参数,包括批量大小、学习率、权重衰减系数、梯度裁剪阈值以及设备选择(如 GPU)。`ema_rate` 控制指数移动平均(EMA)的更新速率,有助于提升模型稳定性。这些参数直接影响训练收敛速度和最终性能。 #### 日志与评估配置 ```yaml logging: log_interval: 100 save_interval: 1000 eval_interval: 5000 wandb_project: diffusion_policy ``` `logging` 部分控制训练过程中的日志记录频率、模型保存周期以及评估间隔。`wandb_project` 指定 Weights & Biases 项目名称,便于可视化训练过程并监控各项指标。通过定期评估和记录,可以及时发现训练异常并调整超参数。 #### 环境与推理设置 ```yaml env_runner: _target_: diffusion_policy.env_runner.pusht_image_env_runner.PushtImageEnvRunner max_episodes: 10 n_obs_steps: 8 n_action_steps: 8 fps: 10 ``` `env_runner` 指定了环境执行器,用于在训练过程中验证策略的表现。`max_episodes` 控制每次评估的最大回合数,`n_obs_steps` 和 `n_action_steps` 分别表示观察窗口和动作预测的步数。`fps` 设置控制器的执行频率,确保与实际机器人或仿真环境同步。 #### 自定义函数解析支持 ```yaml OmegaConf.register_new_resolver("eval", eval, replace=True) ``` 该行代码注册了一个新的 OmegaConf 解析器,允许在配置文件中直接使用 Python 表达式进行动态计算。例如,在 YAML 中可以写入 `batch_size: ${eval:"int(64 * 1.5)"}` 来自动调整批量大小。这种机制提升了配置灵活性,尤其适用于多实验场景下的参数调节。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

往事如yan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值