当前位置:首页>python>Python PyTorch 库详细介绍

Python PyTorch 库详细介绍

  • 2026-03-12 02:03:50
Python PyTorch 库详细介绍

PyTorch 是由 Facebook 人工智能研究院(FAIR)于2016年开源的深度学习框架,以其动态计算图、Python 优先的设计理念和强大的GPU加速能力,迅速成为深度学习研究和工业界的主流框架之一。它不仅提供了构建神经网络所需的基础组件,还拥有一个庞大且活跃的生态系统,覆盖从研究到生产部署的各个环节。

1. 设计哲学与核心优势

PyTorch 的设计深受 Python 生态影响,旨在提供最大的灵活性和易用性。

动态计算图(Define-by-Run):计算图在每次前向传播时动态构建,允许模型结构在运行时改变(如条件分支、循环)。这使得调试直观,代码更接近标准 Python 逻辑,特别适合研究新模型。

Python 优先:PyTorch 与 Python 深度集成,使用方式与 NumPy 高度相似,学习曲线平缓。任何熟悉 Python 和 NumPy 的开发者都可以快速上手。

张量计算与GPU加速:核心数据结构 torch.Tensor 支持高效的数学运算,并能无缝地在 CPU 和 GPU 之间切换,实现大规模并行计算。

自动微分:基于动态计算图的自动微分引擎 torch.autograd 可以自动计算梯度,极大简化了反向传播的实现。

丰富的生态系统:围绕 PyTorch 构建了多个领域库(视觉、文本、音频)和高级工具(PyTorch Lightning、Hugging Face Transformers 等),覆盖了从数据加载到模型部署的全流程。

2. 核心组件详解

2.1 torch:张量计算库

torch 模块是 PyTorch 的基础,提供了多维张量(Tensor)的数据结构及其操作。

张量(Tensor)

张量类似于 NumPy 的 ndarray,但增加了 GPU 加速和自动微分功能。

创建张量:

import torch# 从列表创建a = torch.tensor([[1, 2], [3, 4]])# 创建特殊张量zeros = torch.zeros(3, 4)          # 全零ones = torch.ones(2, 3)             # 全一rand = torch.randn(3, 3)            # 标准正态分布随机数arange = torch.arange(0, 10, 2)     # [0,2,4,6,8]

属性:

shape / size():张量的形状。

dtype:数据类型(如 torch.float32,torch.int64)。

device:所在设备(CPU 或 GPU)。

设备管理:

if torch.cuda.is_available():    device = torch.device('cuda')    a_gpu = a.to(device)            # 移动到 GPU    a_cpu = a_gpu.cpu()              # 移回 CPU

基本运算:支持 NumPy 风格的广播、索引、切片、数学运算(+, -, *, /, @ 等)。

与 NumPy 互操作:

import numpy as npnp_array = np.array([1, 2, 3])tensor_from_np = torch.from_numpy(np_array)   # NumPy -> Tensornp_from_tensor = tensor_from_np.numpy()       # Tensor -> NumPy

注意:转换后的张量与 NumPy 数组共享内存(如果张量在 CPU 上),修改会影响对方。

2.2 torch.autograd:自动微分引擎

torch.autograd 是实现神经网络训练的核心,它自动记录张量上的所有操作,并构建计算图,用于后续的梯度计算。

核心概念:

requires_grad:设置张量需要梯度信息。只有设置了该标志的张量,其操作才会被记录。

计算图:记录了数据(张量)和操作(函数)的有向无环图(DAG)。叶子节点通常是输入张量或模型参数,根节点是损失函数。

反向传播:调用 loss.backward() 从根节点开始,沿计算图反向传播梯度,梯度会累积到每个张量的 .grad 属性中。

示例:

x = torch.tensor([2.0], requires_grad=True)y = x ** 2 + 3 * xy.backward()          # 自动计算梯度 dy/dx = 2*x + 3print(x.grad)         # tensor([7.])

重要细节:

默认情况下,每次反向传播后计算图会被释放以节省内存。若需多次反向传播(如计算高阶梯度),需在 backward() 中设置 retain_graph=True。

使用 torch.no_grad() 上下文管理器可以临时禁用自动梯度记录,常用于评估或推理阶段以减少内存消耗。

2.3 torch.nn:神经网络构建模块

torch.nn 提供了构建神经网络所需的所有组件,以模块化的方式组织。

2.3.1 nn.Module:所有神经网络模型的基类

自定义模型需继承 nn.Module,并在 __init__ 中定义层,在 forward 中定义前向传播逻辑。

import torch.nn as nnimport torch.nn.functional as Fclass MyModel(nn.Module):    def __init__(self):        super().__init__()        self.conv1 = nn.Conv2d(1323)   # 卷积层        self.fc = nn.Linear(32 * 26 * 2610)  # 全连接层    def forward(self, x):        x = self.conv1(x)        x = F.relu(x)        # 也可以使用 nn.ReLU()        x = torch.flatten(x, 1)        x = self.fc(x)        return x

2.3.2 常用层类型

线性层:nn.Linear(in_features, out_features, bias=True)

卷积层:nn.Conv1d/2d/3d,参数包括输入通道、输出通道、卷积核大小等。

循环层:nn.RNN, nn.LSTM, nn.GRU。

规范化层:nn.BatchNorm2d, nn.LayerNorm。

激活函数:nn.ReLU, nn.Sigmoid, nn.Tanh(也可在 F 中作为函数使用)。

池化层:nn.MaxPool2d, nn.AvgPool2d。

Dropout:nn.Dropout。

2.3.3 损失函数

torch.nn 提供了多种损失函数:

nn.MSELoss:均方误差(回归)

nn.CrossEntropyLoss:交叉熵(分类,包含 LogSoftmax + NLLLoss)

nn.BCEWithLogitsLoss:二元交叉熵(包含 Sigmoid)

自定义损失:可以通过继承 nn.Module 或直接使用 Python 函数实现。

2.3.4 参数管理

model.parameters():返回模型所有可训练参数的迭代器,用于优化器。

model.named_parameters():返回参数名和参数本身的迭代器。

model.state_dict():返回模型所有参数(及持久缓冲区)的字典,用于保存/加载。

model.to(device):将整个模型移动到指定设备。

2.4 torch.optim:优化算法

torch.optim 提供了各种优化器,用于根据梯度更新模型参数,从而最小化损失函数。

2.4.1 常用优化器

optim.SGD:随机梯度下降(支持动量、Nesterov)。

optim.Adam:Adaptive Moment Estimation,自适应学习率方法,最常用。

optim.RMSprop:常用于强化学习。

optim.Adagrad, optim.AdamW(Adam 的权重衰减修正版,常用于 Transformer)。

2.4.2 基本用法

optimizer = optim.Adam(model.parameters(), lr=0.001, weight_decay=1e-5)# 训练循环中:optimizer.zero_grad()   # 清除之前梯度loss.backward()         # 计算当前梯度optimizer.step()        # 更新参数

2.4.3 学习率调度

torch.optim.lr_scheduler 提供了多种学习率调整策略,如 StepLR, ReduceLROnPlateau, CosineAnnealingLR 等。

scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=30, gamma=0.1)# 每个 epoch 后调用 scheduler.step()

2.5 torch.utils.data:数据加载工具

高效的数据加载是训练的关键。torch.utils.data 提供了两个核心类:Dataset 和 DataLoader。

2.5.1 Dataset

Dataset 是一个抽象类,需要实现 __len__ 和 __getitem__ 方法。PyTorch 提供了常用数据集的实现(如 torchvision.datasets.ImageFolder),也支持自定义。

from torch.utils.data import Datasetclass MyDataset(Dataset):    def __init__(self, data_list, transform=None):        self.data = data_list        self.transform = transform    def __len__(self):        return len(self.data)    def __getitem__(self, idx):        sample = self.data[idx]        if self.transform:            sample = self.transform(sample)        return sample

2.5.2 DataLoader

DataLoader 负责将 Dataset 包装,提供批处理、打乱、多进程加载等功能。

from torch.utils.data import DataLoaderdataloader = DataLoader(dataset, batch_size=32, shuffle=True, num_workers=4)for batch in dataloader:    # 训练代码    pass

关键参数:

batch_size:每个 batch 的大小。

shuffle:是否在每个 epoch 前打乱数据。

num_workers:用于数据加载的子进程数,加速 I/O。

collate_fn:自定义如何将多个样本组合成一个 batch(对于变长序列尤其重要)。

2.5.3 Sampler

用于定义索引的采样策略,如 RandomSampler, SequentialSampler, WeightedRandomSampler 等。

2.6 模型保存与加载

PyTorch 提供了灵活的方式来保存和加载模型。

保存/加载参数(推荐):

# 保存torch.save(model.state_dict(), 'model_weights.pth')# 加载model = MyModel()model.load_state_dict(torch.load('model_weights.pth'))

保存完整模型(包括结构):

torch.save(model, 'model_full.pth')model = torch.load('model_full.pth')

这种方式依赖于模型类定义的位置,不够灵活,通常不推荐。

保存检查点(checkpoint):包含 epoch、优化器状态等,用于恢复训练。

torch.save({    'epoch': epoch,    'model_state_dict': model.state_dict(),    'optimizer_state_dict': optimizer.state_dict(),    'loss': loss,}, 'checkpoint.pth')

3. 完整训练流程示例(图像分类)

下面以 MNIST 手写数字识别为例,展示一个完整的 PyTorch 训练流程。

import torchimport torch.nn as nnimport torch.optim as optimfrom torch.utils.data import DataLoaderfrom torchvision import datasets, transforms# 1. 数据准备transform = transforms.Compose([    transforms.ToTensor(),    transforms.Normalize((0.1307,), (0.3081,))  # MNIST 均值和标准差])train_dataset = datasets.MNIST(root='./data', train=True, download=True, transform=transform)test_dataset = datasets.MNIST(root='./data', train=False, transform=transform)train_loader = DataLoader(train_dataset, batch_size=64, shuffle=True)test_loader = DataLoader(test_dataset, batch_size=1000, shuffle=False)# 2. 定义模型class Net(nn.Module):    def __init__(self):        super().__init__()        self.conv1 = nn.Conv2d(13231)        self.conv2 = nn.Conv2d(326431)        self.dropout1 = nn.Dropout2d(0.25)        self.fc1 = nn.Linear(9216128)        self.dropout2 = nn.Dropout2d(0.5)        self.fc2 = nn.Linear(12810)    def forward(self, x):        x = self.conv1(x)        x = nn.ReLU()(x)        x = self.conv2(x)        x = nn.ReLU()(x)        x = nn.MaxPool2d(2)(x)        x = self.dropout1(x)        x = torch.flatten(x, 1)        x = self.fc1(x)        x = nn.ReLU()(x)        x = self.dropout2(x)        x = self.fc2(x)        output = nn.LogSoftmax(dim=1)(x)        return outputdevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')model = Net().to(device)# 3. 定义损失函数和优化器criterion = nn.CrossEntropyLoss()optimizer = optim.Adam(model.parameters(), lr=0.001)# 4. 训练循环epochs = 5for epoch in range(1, epochs + 1):    model.train()    for batch_idx, (data, target) in enumerate(train_loader):        data, target = data.to(device), target.to(device)        optimizer.zero_grad()        output = model(data)        loss = criterion(output, target)        loss.backward()        optimizer.step()        if batch_idx % 100 == 0:            print(f'Epoch {epoch} [{batch_idx*len(data)}/{len(train_loader.dataset)}] Loss: {loss.item():.6f}')# 5. 测试model.eval()test_loss = 0correct = 0with torch.no_grad():    for data, target in test_loader:        data, target = data.to(device), target.to(device)        output = model(data)        test_loss += criterion(output, target).item()        pred = output.argmax(dim=1, keepdim=True)        correct += pred.eq(target.view_as(pred)).sum().item()test_loss /= len(test_loader)print(f'Test set: Average loss: {test_loss:.4f}, Accuracy: {correct}/{len(test_loader.dataset)} ({100.*correct/len(test_loader.dataset):.2f}%)')

4. 高级特性与实践技巧

4.1 动态图与自定义 autograd 函数

动态图使得调试简单,同时允许我们通过继承 torch.autograd.Function 自定义反向传播。

class MyReLU(torch.autograd.Function):    @staticmethod    def forward(ctx, input):        ctx.save_for_backward(input)        return input.clamp(min=0)    @staticmethod    def backward(ctx, grad_output):        input, = ctx.saved_tensors        grad_input = grad_output.clone()        grad_input[input < 0] = 0        return grad_input

4.2 混合精度训练

利用 torch.cuda.amp 可以自动混合精度训练,加快训练速度并减少显存占用。

from torch.cuda.amp import autocast, GradScalerscaler = GradScaler()for data, target in train_loader:    optimizer.zero_grad()    withautocast():        output = model(data)        loss = criterion(output, target)    scaler.scale(loss).backward()    scaler.step(optimizer)    scaler.update()

4.3 分布式训练

PyTorch 支持多种分布式训练方式:

torch.nn.DataParallel:单机多卡,简单但效率较低(已逐步被 DistributedDataParallel 替代)。

torch.nn.parallel.DistributedDataParallel(DDP):多机多卡,更高效,推荐使用。

torch.distributed 提供了底层通信原语。

4.4 模型部署

训练好的模型需要部署到生产环境时,PyTorch 提供了多种方案:

TorchScript:将 PyTorch 模型转换为可序列化、可优化的中间表示,可以在 C++ 等无 Python 环境中运行。

traced_script_module = torch.jit.trace(model, example_input)traced_script_module.save("model.pt")

ONNX:Open Neural Network Exchange 格式,支持跨框架(如 ONNX Runtime、TensorRT)部署。

torch.onnx.export(model, dummy_input, "model.onnx")

LibTorch:PyTorch 的 C++ 前端,可直接加载 TorchScript 模型进行推理。

4.5 性能优化

torch.compile:PyTorch 2.0 引入的编译模式,通过内核融合等技术提升模型执行速度。

model = torch.compile(model)

张量核心(Tensor Cores):在支持 Tensor Cores 的 GPU 上,使用混合精度训练并设置尺寸为 8 的倍数可以自动利用。

减少 CPU-GPU 数据传输:尽量将数据预先放在 GPU 上,使用 pin_memory=True 加速 CPU->GPU 传输。

5. 生态系统与社区

PyTorch 的强大离不开其丰富的生态系统。

5.1 官方领域库

TorchVision:包含常用数据集、预训练模型(ResNet, EfficientNet 等)、图像变换工具。

TorchAudio:音频 I/O、数据增强、预训练模型(如 Wav2Vec2)。

TorchText:文本数据处理、预训练词向量、数据集。

TorchRec:推荐系统专用库。

5.2 第三方库

PyTorch Lightning:简化训练脚本,将工程代码与研究代码分离,提供 Trainer、Callback 等高级抽象。

Hugging Face Transformers:提供数千种预训练 Transformer 模型(BERT, GPT, T5 等)和训练工具。

FastAI:基于 PyTorch 的高级框架,提供易于使用的 API 和最佳实践。

Captum:模型可解释性工具,帮助理解模型决策。

Weights & Biases (wandb):实验跟踪与可视化。

5.3 社区与资源

PyTorch 论坛(discuss.pytorch.org):活跃的问答社区。

GitHub:官方代码仓库,issue 和 PR 丰富。

PyTorch 教程(pytorch.org/tutorials):官方教程涵盖从入门到高级。

Papers with Code:大量研究论文的实现基于 PyTorch。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 21:44:39 HTTP/2.0 GET : https://f.mffb.com.cn/a/479309.html
  2. 运行时间 : 0.194006s [ 吞吐率:5.15req/s ] 内存消耗:4,612.09kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=4288a0035b8f3b54a72142972d429254
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.001024s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001653s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000733s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.004387s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000644s ]
  6. SELECT * FROM `set` [ RunTime:0.000239s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000718s ]
  8. SELECT * FROM `article` WHERE `id` = 479309 LIMIT 1 [ RunTime:0.007408s ]
  9. UPDATE `article` SET `lasttime` = 1774619080 WHERE `id` = 479309 [ RunTime:0.007336s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.002125s ]
  11. SELECT * FROM `article` WHERE `id` < 479309 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000538s ]
  12. SELECT * FROM `article` WHERE `id` > 479309 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000540s ]
  13. SELECT * FROM `article` WHERE `id` < 479309 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001004s ]
  14. SELECT * FROM `article` WHERE `id` < 479309 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.010086s ]
  15. SELECT * FROM `article` WHERE `id` < 479309 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.009000s ]
0.195615s