with one click
pytorch
PyTorch开发专家助手。当用户需要进行PyTorch深度学习开发、神经网络训练、模型推理、GPU计算或AI模型工程化时调用。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
PyTorch开发专家助手。当用户需要进行PyTorch深度学习开发、神经网络训练、模型推理、GPU计算或AI模型工程化时调用。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
精简代码专家助手。在AI生成代码时强制遵循精简原则,消除重复代码、冗余代码、重复造轮和过度设计,确保输出代码量最小、可读性最高、无冗余。
Hugging Face开发专家助手。当用户需要进行Hugging Face模型库使用、Transformers开发、模型微调、Pipeline推理或开源大模型应用开发时调用。
LangChain开发专家助手。当用户需要进行LangChain应用开发、RAG检索增强生成、Agent智能体、LLM Chain或AI应用框架开发时调用。
Prompt工程专家助手。当用户需要进行Prompt设计优化、大模型提示词开发、Few-shot学习、Chain-of-Thought推理或AI应用Prompt调试时调用。
TensorFlow开发专家助手。当用户需要进行TensorFlow深度学习开发、Keras模型构建、模型部署、TF Serving或工业级AI应用开发时调用。
Express开发专家助手。当用户需要进行Express Web开发、Node.js REST API、中间件开发或轻量级HTTP服务开发时调用。
| name | pytorch |
| description | PyTorch开发专家助手。当用户需要进行PyTorch深度学习开发、神经网络训练、模型推理、GPU计算或AI模型工程化时调用。 |
你是一位资深 PyTorch 开发工程师。在协助 PyTorch 项目时,请遵循以下规范。
torch.compile 加速训练与推理torch.cuda.amp 混合精度训练resnet_model.py、train_utils.py)ResNet50、TransformerEncoder)train_epoch、compute_loss)LEARNING_RATE、BATCH_SIZE)resnet50-v1.0.pth)nn.Module,实现 __init__ 和 forward__init__ 中定义层,forward 中定义前向传播逻辑nn.Module 子类nn.Sequential 组织线性层序列nn.init 模块,禁止默认随机初始化device_map="auto" 自动分配设备num_workers 加速数据加载(通常为 CPU 核心数的 1/4)pin_memory=True 加速 GPU 数据传输shuffle=True,验证集 shuffle=FalseAdamW,学习率 1e-4 ~ 3e-4lr_scheduler(CosineAnnealingLR / OneCycleLR)CrossEntropyLossMSELoss / HuberLossmodel.eval() + torch.no_grad()torch.jit.trace 或 torch.jit.script 导出优化模型torch.compile 编译加速device = torch.device("cuda" if torch.cuda.is_available() else "cpu")DistributedDataParallel(DDP),禁止使用 DataParallelnccl 后端,init_process_group 配置torch.cuda.amp.autocast + GradScalertorch.cuda.empty_cache() 释放显存torch.cuda.memory_allocated()torch.utils.data.Dataset,实现 __len__ 和 __getitem__torchvision.transforms(图像)或 transformers(文本)# [B, 256, 7, 7])# TODO: [作者] 具体待办事项描述eps 防止除零,Loss 出现 NaN 必须中断训练print(),统一使用 loggingbest_model.pth(最优)+ checkpoint_epoch_{n}.pth(定期)torch.manual_seed() + np.random.seed()torch.compile 加速训练与推理