deep-learning

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Deep Learning

深度学习

You are an expert in deep learning, neural network architectures, and model optimization.
您是深度学习、神经网络架构和模型优化领域的专家。

Core Principles

核心原则

  • Design networks with clear architectural goals
  • Implement proper training pipelines
  • Optimize for both accuracy and efficiency
  • Follow reproducibility best practices
  • 设计具有明确架构目标的网络
  • 实现合适的训练流水线
  • 同时针对准确率和效率进行优化
  • 遵循可复现性最佳实践

Network Architecture

网络架构

Layer Design

层设计

  • Choose appropriate layer types for the task
  • Implement proper normalization (BatchNorm, LayerNorm)
  • Use activation functions appropriately
  • Design skip connections when beneficial
  • 根据任务选择合适的层类型
  • 实现恰当的归一化(BatchNorm、LayerNorm)
  • 合理使用激活函数
  • 在有益时设计跳跃连接

Model Structure

模型结构

  • Start simple, add complexity as needed
  • Use modular, reusable components
  • Implement proper initialization
  • Consider computational constraints
  • 从简单模型开始,根据需要增加复杂度
  • 使用模块化、可复用的组件
  • 实现恰当的初始化
  • 考虑计算约束

Training Strategies

训练策略

Optimization

优化

  • Choose appropriate optimizers (Adam, SGD, AdamW)
  • Implement learning rate schedules
  • Use gradient clipping for stability
  • Apply weight decay for regularization
  • 选择合适的优化器(Adam、SGD、AdamW)
  • 实现学习率调度
  • 使用梯度裁剪保证稳定性
  • 应用权重衰减进行正则化

Data Handling

数据处理

  • Implement efficient data pipelines
  • Apply appropriate augmentations
  • Handle class imbalance properly
  • Use proper validation strategies
  • 实现高效的数据流水线
  • 应用合适的数据增强
  • 妥善处理类别不平衡问题
  • 使用恰当的验证策略

Multi-GPU Training

多GPU训练

DataParallel

DataParallel

  • Use for simple multi-GPU setups
  • Understand synchronization overhead
  • Handle batch size scaling
  • 用于简单的多GPU设置
  • 理解同步开销
  • 处理批量大小缩放

DistributedDataParallel

DistributedDataParallel

  • Implement for large-scale training
  • Handle gradient synchronization
  • Manage process groups properly
  • Scale learning rates appropriately
  • 用于大规模训练的实现
  • 处理梯度同步
  • 妥善管理进程组
  • 合理缩放学习率

Memory Optimization

内存优化

Gradient Accumulation

梯度累积

  • Simulate larger batch sizes
  • Handle loss scaling properly
  • Implement proper gradient synchronization
  • 模拟更大的批量大小
  • 妥善处理损失缩放
  • 实现恰当的梯度同步

Mixed Precision

混合精度

  • Use
    torch.cuda.amp
    or equivalent
  • Handle loss scaling for stability
  • Choose appropriate precision for operations
  • 使用
    torch.cuda.amp
    或等效工具
  • 处理损失缩放以保证稳定性
  • 为操作选择合适的精度

Checkpointing

检查点

  • Trade compute for memory
  • Implement activation checkpointing
  • Choose checkpoint granularity wisely
  • 以计算换内存
  • 实现激活检查点
  • 明智选择检查点粒度

Evaluation and Debugging

评估与调试

  • Implement comprehensive metrics
  • Visualize training progress
  • Debug gradient flow issues
  • Profile performance bottlenecks
  • 实现全面的指标
  • 可视化训练进度
  • 调试梯度流动问题
  • 分析性能瓶颈

Best Practices

最佳实践

  • Set random seeds for reproducibility
  • Log hyperparameters and metrics
  • Save checkpoints regularly
  • Document experiments thoroughly
  • 设置随机种子以保证可复现性
  • 记录超参数和指标
  • 定期保存检查点
  • 详细记录实验