《PyTorch面试精华》


1 前言
    1.1  PyTorch安装

    1.2  显卡驱动的困惑

    1.3  CUDA安装注意事项

    1.4  cuDNN的介绍

    1.5  Pytorch Lightning介绍

    1.6  PyTorch学习之道

    1.7  PyTorch快速入门

    1.8  PyTorch调参之道

    1.9  PyTorch调参套件

    1.10  手动创建虚拟环境

2 深度学习之数学基础
    2.1  希腊字母解读

    2.2  梯度的物理意义

    2.3  图解梯度下降法

    2.4  图解梯度上升法

    2.5  自然梯度

    2.6  泰勒公式的介绍

    2.7  信息与信息熵

    2.8  重要性采样

    2.10  欧几里得范数

    2.11  特征值和特征向量

    2.12  似然函数的理解

    2.13  矩阵秩的深刻理解

3 PyTorch入门疑难点
4 PyTorch全局设置
    4.1  全局设置当前设备

    4.2  全局设置浮点精度

5 PyTorch GPU分布式训练
    5.1  PyTorch GPU基础操作

    5.2  DataParallel用法详解

    5.3  GPU分布式训练模型

    5.4  CUDA_VISIBLE_DEVICES

    5.5  device详细说明

    5.6  to(device)和.cuda()

    5.7  CUDA设备索引

    5.8  GPU设备索引

6 向量的基础与核心
    6.1  Tensor的组成与存储

    6.2  Tensor的grad属性

    6.4  Tensor的叠加

    6.5  禁用梯度计算

    6.6  向量的保存和加载

    6.7  参数向量

    6.8  叶子节点

    6.9  detach原理

    6.10  requires_grad属性

    6.11  Tensor与Numpy互换

    6.12  张量cat操作

    6.13  零维张量

    6.15  squeeze/unsqu...函数

    6.16  argmax和max的区别

    6.17  torch.as_tensor的应用

7 神经网络基础
    7.2  PyTorch计算图

    7.3  查看网络权重参数

    7.4  保存模型

    7.5  Adam相关面试题

    7.6  Train模式和Eval模式

    7.7  线性网络

    7.8  双线性网络

    7.9  惰性线性层

    7.10  PyTorch中的自动微分

    7.12  Dropout机制

    7.13  半精度训练

    7.14  Xavier初始化

    7.15  注意力机制

    7.16  Dataset数据处理

    7.17  StepLR学习率调度器

    7.18  词嵌入的理解

    7.19  TensorDataset的使用

    7.20  模型的保存与加载

    7.21  ModuleList和Sequential

    7.22  Batch Normalization介绍

8 计算机视觉基础知识
    8.1  通道的深刻理解

    8.2  1x1卷积的作用

    8.3  特征提取和可视化

    8.4  反卷积的推导

    8.5  理解卷积

    8.7  空洞卷积

    8.8  池化层的作用

    8.9  感受野与特征图

    8.10  NMS算法

    8.11  特征图尺寸计算

9 循环神经网络基础
    9.2  RNN的介绍

10 注意力机制
    10.1  位置编码的作用

    10.2  位置编码的种类

    10.4  Embedding本质理解

    10.6  Transformer VS CNN/RNN

    10.7  ELMo介绍

11 PyTorch归一化
    11.2  层归一化技术详解

12 激活函数相关内容
    12.1  激活函数简介

    12.2  万能逼近定理

    12.3  指数函数的学习

    12.4  Sigmoid函数的介绍

    12.5  Tanh函数的介绍

    12.6  Softmax函数的实现

    12.7  ReLU函数的介绍

    12.8  Leaky Relu函数的介绍

    12.9  ReLu与非线性的理解

    12.10  Parametric ReLU函数

    12.11  ELU函数介绍

    12.12  神经元死亡的问题

13 思考题的答案
    13.1  思考题的答案解密

设置控制台输出格式

创建时间:2024-09-10 更新时间:2024-09-10 阅读次数:2091 次

提示:平心而论,此内容不属于面试题,没有可考性,但是对大家平时代码调试很有帮助,所以我就收录进来,自成一个小节。

torch.set_printoptions函数用于设置打印选项:

torch.set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, profile=None, sci_mode=None)

参数介绍:

  • precision – Number of digits of precision for floating point output (default = 4).
  • threshold – Total number of array elements which trigger summarization rather than full repr (default = 1000).
  • edgeitems – Number of array items in summary at beginning and end of each dimension (default = 3).
  • linewidth – The number of characters per line for the purpose of inserting line breaks (default = 80). Thresholded matrices will ignore this parameter.
  • profile – Sane defaults for pretty printing. Can override with any of the above options. (any one of default, short, full)
  • sci_mode – Enable (True) or disable (False) scientific notation. If None (default) is specified, the value is defined by torch._tensor_str._Formatter. This value is automatically chosen by the framework.

说明:参数设置来源于NumPy。Pytorch官方用调侃的口吻说:Items shamelessly taken from NumPy。

代码举例:

>>> # Limit the precision of elements
>>> torch.set_printoptions(precision=2)
>>> torch.tensor([1.12345])
tensor([1.12])
>>> # Limit the number of elements shown
>>> torch.set_printoptions(threshold=5)
>>> torch.arange(10)
tensor([0, 1, 2, ..., 7, 8, 9])
>>> # Restore defaults
>>> torch.set_printoptions(profile="default")
>>> torch.tensor([1.12345])
tensor([1.1235])
>>> torch.arange(10)
tensor([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
本教程共117节,当前为第32节!
本教程最新修订时间为:2026-05-08 11:10:53