Repository navigation
FAQ
zimingttkx edited this page Dec 13, 2025
·
1 revision
常见问题解答。
推荐使用 Conda 创建隔离环境:
conda create -n ai-practices python=3.10 -y
conda activate ai-practices
pip install -r requirements.txt- 确保 Python 版本为 3.10.x
- 升级 pip:
pip install --upgrade pip - Mac M1/M2/M3 使用:
pip install tensorflow-macos tensorflow-metal
# 检查 TensorFlow GPU
import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))
# 检查 PyTorch GPU
import torch
print(torch.cuda.is_available())如果不可用,检查 CUDA 和 cuDNN 版本是否匹配。
为 Jupyter 注册环境:
python -m ipykernel install --user --name=ai-practices然后在 Notebook 中选择正确的 Kernel。
- 清理输出: Cell → All Output → Clear
- 重启 Kernel: Kernel → Restart
- 减小数据量进行测试
- 降低学习率
- 检查数据中是否有 NaN/Inf 值
- 添加梯度裁剪:
optimizer = Adam(clipnorm=1.0)
- 添加正则化 (L1/L2)
- 使用 Dropout
- 数据增强
- 早停 (Early Stopping)
- 减小模型容量
# TensorFlow: 设置内存增长
gpus = tf.config.experimental.list_physical_devices('GPU')
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
# 减小 batch_size
# 使用混合精度训练推荐先学机器学习基础 (Module 01):
- 理解基本概念(损失函数、优化、过拟合等)
- 掌握数据预处理和特征工程
- 深度学习是机器学习的子集
- 初学者: 从 Keras (TensorFlow) 开始
- 研究者: PyTorch 更灵活
- 工程师: TensorFlow 部署方便
- 建议: 两者都学,本项目两者都覆盖
没找到答案?请在 GitHub Issues 中搜索或提问。
AI-Practices | GitHub | Documentation | MIT License