代码阅读 :SECOND pytorch版本

点云检测算法之PointPillar深度解读 介绍损失函数前这里介绍下PP的Anchor的设计,由于PP是基于点云数据的俯视图的表示,所以这里初始化的矛框有着不同于图像的矛框的设计,不同于图像的远小近大的特点,点云数据拥有者几何不变性的特点,所以在这里我们可以直接利用不同类别的先验知识来初始化矛框,下面是车辆和行人的矛框的初始化。PS:虽然矛框是3D的,但是再与GT匹配的时候,只采用2D的信息。现在在目标检测的领域的基本上是标配,主要解决的问题就是多尺度变换的不足,高层的特征虽然包含了丰富的语义信息,但是由于低分辨率,很难准确地保存物体的位置信息。 阅读详情

代码量很大。。。

框架

second.pytorch --------
                 |---images
                 |---second ----|---apex
                 |---torchplus  |---builder
                                |---configs
                                |---core
                                |---data
                                |---framework
                                |---kittiviewer
                                |---protos
                                |---pytorch ------|---builder
                                |---spconv        |---core
                                |---utils         |---models
                                                  |---utils

上述的代码主要工程树,简单说下每个文件夹下面的代码功能:

  • apex与spconv是进行second.pytorch安装的第三方依赖库;
  • builder为基础网络的构建基础代码;
  • configs为网络参数配置文件夹;
  • core为基础功能文件夹,包括anchor、box_coder等些实现;
  • data文件夹为数据处理模块;
  • framework文件暂不清楚,好像是测试模块;
  • kittiviewer很显然为可视化功能模块;
  • protos模块读取内部的proto才构成py文件,具体不太清楚(理解后来填坑);
  • pytorch文件夹为second.pytorch的核心,涉及训练、预测、网络等代码;
  • utils为基础功能文件夹;

configs文件夹

car.fhd.config

model: {
  second: {
    network_class_name: "VoxelNet"
    # 体素生成
    voxel_generator {
      point_cloud_range : [0, -40, -3, 70.4, 40, 1]  # 点云范围
      # point_cloud_range : [0, -32.0, -3, 52.8, 32.0, 1]
      voxel_size : [0.05, 0.05, 0.1]  # 体素大小
      max_number_of_points_per_voxel : 5  # 每个体素的最大点数
    }
    # 体素特征提取器
    voxel_feature_extractor: {
      module_class_name: "SimpleVoxel"
      num_filters: [16]
      with_distance: false
      num_input_features: 4
    }
    # 中间特征提取器
    middle_feature_extractor: {
      module_class_name: "SpMiddleFHD"
      # num_filters_down1: [] # protobuf don't support empty list.
      # num_filters_down2: []
      downsample_factor: 8
      num_input_features: 4
    }
    # RPN网络
    rpn: {
      module_class_name: "RPNV2"
      layer_nums: [5]
      layer_strides: [1]
      num_filters: [128]
      upsample_strides: [1]
      num_upsample_filters: [128]
      use_groupnorm: false
      num_groups: 32
      num_input_features: 128
    }
    # 损失函数
    loss: {
      classification_loss: {
        weighted_sigmoid_focal: {
          alpha: 0.25
          gamma: 2.0
          anchorwise_output: true
        }
      }
      localization_loss: {
        weighted_smooth_l1: {
          sigma: 3.0
          code_weight: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        }
      }
      classification_weight: 1.0
      localization_weight: 2.0
    }
    num_point_features: 4 # model's num point feature should be independent of dataset
    # Outputs
    use_sigmoid_score: true
    encode_background_as_zeros: true
    encode_rad_error_by_sin: true
    sin_error_factor: 1.0

    use_direction_classifier: true # this can help for orientation benchmark
    direction_loss_weight: 0.2 # enough.
    num_direction_bins: 2
    direction_limit_offset: 1

    # Loss
    pos_class_weight: 1.0
    neg_class_weight: 1.0

    loss_norm_type: NormByNumPositives
    # Postprocess
    post_center_limit_range: [0, -40, -2.2, 70.4, 40, 0.8]
    nms_class_agnostic: false # only valid in multi-class nms

    box_coder: {
      ground_box3d_coder: {
        linear_dim: false
        encode_angle_vector: false
      }
    }
    target_assigner: {
      class_settings: {
        anchor_generator_range: {
          sizes: [1.6, 3.9, 1.56] # wlh
          anchor_ranges: [0, -40.0, -1.00, 70.4, 40.0, -1.00] # carefully set z center
          rotations: [0, 1.57] # DON'T modify this unless you are very familiar with my code.
        }
        matched_threshold : 0.6
        unmatched_threshold : 0.45
        class_name: "Car"
        use_rotate_nms: true
        use_multi_class_nms: false
        nms_pre_max_size: 1000
        nms_post_max_size: 100
        nms_score_threshold: 0.3 # 0.4 in submit, but 0.3 can get better hard performance
        nms_iou_threshold: 0.01

        region_similarity_calculator: {
          nearest_iou_similarity: {
          }
        }
      }
      # anchor_generators: {
      #   anchor_generator_stride: {
      #     sizes: [1.6, 3.9, 1.56] # wlh
      #     strides: [0.4, 0.4, 0.0] # if generate only 1 z_center, z_stride will be ignored
      #     offsets: [0.2, -39.8, -1.00] # origin_offset + strides / 2
      #     rotations: [0, 1.57] # DON'T modify this unless you are very familiar with my code.
      #     matched_threshold : 0.6
      #     unmatched_threshold : 0.45
      #   }
      # }
      sample_positive_fraction : -1
      sample_size : 512
      assign_per_class: true
    }
  }
}

#训练输入读取器,原batch_size=8,num_workers=3
train_input_reader: {
  dataset: {
    dataset_class_name: "KittiDataset"
    # kitti_info_path: "/media/yy/960evo/datasets/kitti/kitti_infos_train.pkl"
    # kitti_root_path: "/media/yy/960evo/datasets/kitti"
    kitti_info_path: "/home/cv/文档/datasets/KITTI_PP/kitti_infos_train.pkl"
    kitti_root_path: "/home/cv/文档/datasets/KITTI_PP"
  }

  batch_size: 8
  preprocess: {
    max_number_of_voxels: 17000
    shuffle_points: true
    num_workers: 1
    groundtruth_localization_noise_std: [1.0, 1.0, 0.5]
    # groundtruth_rotation_uniform_noise: [-0.3141592654, 0.3141592654]
    # groundtruth_rotation_uniform_noise: [-1.57, 1.57]
    groundtruth_rotation_uniform_noise: [-0.78539816, 0.78539816]
    global_rotation_uniform_noise: [-0.78539816, 0.78539816]
    global_scaling_uniform_noise: [0.95, 1.05]
    global_random_rotation_range_per_object: [0, 0] # pi/4 ~ 3pi/4
    global_translate_noise_std: [0, 0, 0]
    anchor_area_threshold: -1
    remove_points_after_sample: true
    groundtruth_points_drop_percentage: 0.0
    groundtruth_drop_max_keep_points: 15
    remove_unknown_examples: false
    sample_importance: 1.0
    random_flip_x: false
    random_flip_y: true
    remove_environment: false

    #数据库采样器
    database_sampler {
      # database_info_path: "/media/yy/960evo/datasets/kitti/kitti_dbinfos_train.pkl"
      database_info_path: "/home/cv/文档/datasets/KITTI_PP/kitti_dbinfos_train.pkl"
      sample_groups {
        name_to_max_num {
          key: "Car"
          value: 15
        }
      }
      database_prep_steps {
        filter_by_min_num_points {
          min_num_point_pairs {
            key: "Car"
            value: 5
          }
        }
      }
      database_prep_steps {
        filter_by_difficulty {
          removed_difficulties: [-1]
        }
      }
      global_random_rotation_range_per_object: [0, 0]
      rate: 1.0
    }
  }
}

train_config: {
  optimizer: {
    adam_optimizer: {
      learning_rate: {
        one_cycle: {
          lr_max: 2.25e-3
          moms: [0.95, 0.85]
          div_factor: 10.0
          pct_start: 0.4
        }
      }
      weight_decay: 0.01
    }
    fixed_weight_decay: true
    use_moving_average: false
  }
  # steps: 99040 # 1238 * 120
  # steps: 49520 # 619 * 80
  # steps: 30950 # 619 * 80
  # steps_per_eval: 3095 # 619 * 5
  steps: 23200 # 464 * 50
  steps_per_eval: 2320 # 619 * 5

  save_checkpoints_secs : 1800 # half hour
  save_summary_steps : 10
  enable_mixed_precision: false 
  loss_scale_factor: -1
  clear_metrics_every_epoch: true
}

#测试输入读取器,原batch_size=8,num_workers=3
eval_input_reader: {
  dataset: {
    dataset_class_name: "KittiDataset"
    # kitti_info_path: "/media/yy/960evo/datasets/kitti/kitti_infos_val.pkl"
    # # kitti_info_path: "/media/yy/960evo/datasets/kitti/kitti_infos_test.pkl"
    # kitti_root_path: "/media/yy/960evo/datasets/kitti"

    kitti_info_path: "/home/cv/文档/datasets/KITTI_PP/kitti_infos_val.pkl"
    # kitti_info_path: "/home/cv/文档/datasets/KITTI_PP/kitti_infos_test.pkl"
    kitti_root_path: "/home/cv/文档/datasets/KITTI_PP"
  }
  batch_size: 8
  preprocess: {
    max_number_of_voxels: 40000
    shuffle_points: false
    num_workers: 3
    anchor_area_threshold: -1
    remove_environment: false
  }
}

PyTorch手写数字识别实战:从环境配置到模型部署全流程 神经网络是深度学习的核心范式,其本质是通过多层非线性变换实现特征抽象与分类决策。PyTorch凭借动态计算图、Pythonic API和强大生态,成为理解该原理最直观的工程载体。本文以MNIST手写数字识别为切入点,系统覆盖PyTorch环境配置(含CUDA12.8/RTX 5060适配)、Dataset数据加载、nn.Module模型定义、训练循环五步法及GPU显存优化等关键技术环节,兼顾初学者避坑与工业级实践要求。内容自然延伸至迁移学习、模型导出(torch.jit.trace)与TorchServe部 阅读详情

相关推荐

Tokens per Second:大模型推理速度的测量与优化全解析

大语言模型在生成文本时按 token 进行,token 是模型理解文本的基本单元。衡量模型生成速度的关键指标是 tokens per second(tokens/s),它直接决定用户体验与系统吞吐。理解这一指标需要区分单请求速度与并发吞吐,并关注 prefill、decode 阶段以及显存带宽、量化策略等影响因素。在工程实践中,开发者可通过 vLLM 等推理框架、连续批处理、投机解码等手段显著提升 token 生成速度。合理建立评测基准、关注延迟分布,才能在生产环境中复现理想性能。本文围绕 tokens/s

weixin_34411563的博客 391

PointPillars算法解析

**核心思想:** PointPillars算法从俯视图的角度将点云划分为一个个的柱状体(Pillar),等同于丢掉了高度信息,只保留水平方向上的xy坐标,每个柱状体(Pillar)等同于2D图像中的一个像素坐标。在得到伪图像之后使用常见2D网络进行特征的提取和学习,最后使用SSD检测头进行Bbox的回归。

超爱吃小蛋糕的66的博客 2699

机器学习实战书单:9本通过代码验证的工程师工具书

机器学习不是纯数学推演,也不是API调用堆砌,而是理论、代码与工程落地的三角闭环。理解梯度下降的链式法则如何映射到autograd,掌握PyTorch DataLoader的num_workers参数为何设为CPU核心数减一,是工程师突破‘知道但不会改bug’瓶颈的关键。这类能力依赖于具备数学可验证性、代码即时可运行、项目真实可部署的高质量学习资源。本文聚焦2022年实测筛选出的9本高时效性、强实践性的ML书籍,覆盖从线性回归脚本速启、模型可解释性交付,到大模型底层逻辑迁移等典型技术路径,特别适配在职工程师

weixin_30415113的博客 399

PointPillar 3D目标检测模型详解

3D检测论文阅读简记自动驾驶中基于Lidar的object检测,简单的说,就是从3D点云数据中定位到object的框和类别。具体地,输入是点云 $X∈R^{N×c}一般c4,输出是n个检测框bboxes以第i个检测框bbox为例它包括∗∗位姿信息∗∗(一般 c=4 ),输出是 n 个检测框bboxes, 以第 i 个检测框bbox为例, 它==包括**位姿信息**一般c4,输出是n个检测框bboxes以第i个检测框bb。

IT菜鸟 1万+

second.pytorch:用于KITTI对象检测的PointPillars

点柱 欢迎来到PointPillars。 此存储库演示了如何通过对现有开放源代码库进行最小的要求更改,来在上重现(将在CVPR 2019上发布)的。 这不是官方的nuTonomy代码库,但可以用于匹配已发布的PointPillars结果。 警告:此代码未得到积极维护。 此代码可用于在论文的第一个版本重现结果。 对于还可以在nuScenes上重现PointPillars结果的主动维护的存储库,我们建议使用 。 我们不是存储库的所有者,但是我们与作者合作并认可了他的代码。 入门 这是的一个分支,此处复制了原始README的相关子集。 代码支持 仅支持python 3.6 +,pytorch 0.4.1+。 代码仅在Ubuntu 16.04 / 18.04上进行了测试。 安装 1.克隆代码 git clone https://github.com/nutonomy/second.pytor

基于WEKWS模型的语音唤醒关键词识别

本文所使用的模型网络结构继承自论文《Compact Feedforward Sequential Memory Networks for Small-footprint Keyword Spotting》,文中研究了将低秩矩阵分解与传统FSMN相结合的紧凑型前馈顺序记忆网络(cFSMN)用于远场关键字检测任务。

YuZhou的博客 6580

[AI 算法] PointPillar算法

pointpillar 最主要的特点是检测速度和精度的平衡 1. 研究出发点 现有的一些研究喜欢将不规则、稀疏的点云数据按照以下两种方式进行处理,然后引入RPN层进行3D Bbox Proposal,这两种方法为: (1)将点云数据划纳入一个个体素(Voxel)中,构成规则的、密集分布的体素集。常见的有VoxelNet和SECOND,这在之前的文章中已经解析过了; (2)从俯视角度将点云数据进行处理,获得一个个伪图片的数据。常见的模型有MV3D和AVOD,这也说过了。 . 主要是将点云透射到俯视图上,然后

头狼博客 549

SAP 银企直连实战:从零构建 DMEEX 格式树的配置与调试指南

本文详细介绍了SAP银企直连中DMEEX格式树的配置与调试方法,涵盖从基础认知到实战技巧的全流程。通过具体案例解析,帮助财务顾问快速掌握建设银行付款报文的格式树搭建、字段映射及调试优化,提升企业支付效率与准确性。

weixin_42526015的博客 560

点云检测网络 PointPillar

在此之前对于不规则的稀疏的点云的做法普遍分为两派:一是把点云数据量化到一个个Voxel里,常见的有VoxelNet和SECOND , 但是这种做法比较普遍的问题是由于voxel大部分是空集所以会浪费算力(SECOND利用稀疏卷积解决了它) ,但是二者都还存在高度的信息所以还需要计算三维卷积的。一是从俯视角度将点云的数据进行处理,将高度信息通过一系列手段去除从而获得一种类似Pseudo image的方式从而去用一些经典的图像网络去处理一些任务比如,MV3D和AVOD。

人无远虑,必有近忧 2076

帆软 finereport FCRA 考试 题库+答案,共收录561题,大部分有答案

帆软 finereport FCRA 考试 题库+答案,共收录561题,大部分有答案 入门基础 11.多选题 以下方式中属于FineReport中预览模式的有( ) 分页预览、填报预览、新填报预览、数据分析、移动端预览 16.判断题 FineReport报表工具必须购买激活码后才能使用。 错误,可以免费获取激活码。 29.单选题 FineReport是一款利用( )语言开发的报表工具。java 41.多选题 访问帮助文档的方式有哪些?设计器中社区菜单下-帮助文档;直接访问http://help.finere

qq_37485720的博客 2万+

华为手环实时心率数据导出到UWP项目中

hello大家好呀O(∩_∩)O最近在做毕设 其中有个小功能要用到实时心率数据。查找网上的资料发现只有小米手环的实时心率数据导出但是没有华为手环的,我试了华为手环但是并不能行得通哈哈哈。现在分享一下华为手环实时心率数据导出的代码。

apple_63713858的博客 1577

second.pytorch代码分析(code-framework & tricks)

简述 之所以想写这篇博客,主要原因在于阅读别人的代码时候,首先希望把流程架构弄清楚,然后才方便进行修改。second.pytorch代码量比较大,刚开始拿到时候,我也是一头雾水,硬着头皮往下面去看,配置环境(没有跑起来的建议去下载我的docker镜像,深度学习的利器,避免二次配置软件环境问题),让其跑起来方便调试来进行阅读。话不多说,现在开始进行简要分析一下second.pytorch点云检测这部...

AutoXTruck专栏 4469

DNF单机版搭建全攻略:从零开始到局域网联机(含常见问题解决)

本文提供详细的DNF单机版搭建指南,从环境配置到局域网联机设置,涵盖服务端安装、数据库配置及常见问题解决方案。适合新手和有经验的玩家,帮助快速搭建专属游戏服务器,重温经典游戏体验。

weixin_30832143的博客 837

NVIDIA_Jetson_Xavier安装second.pytorch环境

原创 small_munich 最后发布于2019-10-13 10:41:56 阅读数 540 收藏 展开 简述 说起在nvidia的xavier上面安装second.pytorch算法环境,也是醉了。没有什么特别的原因,就是在没有对second.pytorch算法pytorch模型进行tensorrt加速时候,单纯的项测试一下该算法能够跑多少fps,为以后优化过在tensorrt下进行对比...

1299

MOOS-ivp 实验三 MOOS简介(3)

MOOS-ivp 实验三 MOOS简介(3) 继上一篇文章继续对实验进行记录 提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录MOOS-ivp 实验三 MOOS简介(3)六、A Simple Example with pXRelay1.pXRelay基本使用2.pXRelay简单例子3.pXRelay实验七、First Experiments in Modifying MOOS App Code1.下载一个MOOS模板文件2.打开MOOS模板文件总结 六、A Simple E

weixin_44151170的博客 2527

基于MATLAB开发AUTOSAR软件应用层模块-part2.建立一个AUTOSAR的模型,并生成autosar格式代码

上一篇我们建立了一个空模型,这篇我们接着上篇文章,建立一个简单的模型 点击 Library Browser,打开simulink模块库,见下图 左侧是模块库的列表,右侧是每个模块库里包含的具体的模块。 点击通用模块库,里边是一些常见的模块, 我们选取里边的3个模块,分别是输入,输出和增益三个模块,右键点击模块,选择add block to model xx,可以把模块添加到模型中。 然后练好连线 一个简单的模型就搭建好了,之后我们修改配置,将模型修改为AUT...

汽车软件开发 3289

PointPillars阅读及博客

项目地址 https://github.com/traveller59/second.pytorch https://github.com/nutonomy/second.pytorch 代码阅读: https://blog.csdn.net/weixin_40805392 坑: https://blog.csdn.net/qq_35515203/article/details/103887545 https://zhuanlan.zhihu.com/p/73853535 https://blog.csdn

mooooop的博客 699

快手NS sig3签名算法(2025年1月)

快手NS sig3签名算法(2025年1月)

sh_moranliunian的博客 3656

Pytorch中Trying to backward through the graph和one of the variables needed for gradient错误解决方案

Trying to backward through the graph a second time one of the variables needed for gradient computation has been modified by an inplace operation

rothschild666的博客 6025

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

PyTorch RuntimeError: 解决二次反向传播的计算图生命周期管理

在深度学习框架中,自动微分是实现神经网络训练的核心机制,它通过构建动态计算图来追踪张量操作并自动计算梯度。其原理是在前向传播过程中记录所有运算,形成有向无环图,以便在反向传播时应用链式法则。这一机制的技术价值在于极大简化了梯度计算,使开发者能专注于模型设计。然而,若管理不当,例如在梯度累积、GAN交替训练等应用场景中多次调用backward(),就会因计算图被默认释放而触发“RuntimeError: Trying to backward through the graph a second time”错误

weixin_33912453的博客 432

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

pointpillars代码阅读-----架构篇

Brief  目前已经理论知识丰富,但是实践很少,因此决定在这两周内,做以下两件事: 阅读pointpillars代码,侧重点在理解怎么在nuscence上进行多目标检测的。并写笔记。 完成以下网络的搭建:(也即是是voxel的检测) 1 pointpillars代码 1.1 简单介绍 这里是 pytorch的版本 这个版本已经升级到了V2.0,也就是加入了nuscence的检测任务,同时S...

有所为,有所成长 9801

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

OpenPCDet和mmdetection3d

OpenPCDet和mmdetection3d是香港中文大学open-mmlab实验室的成果,这两个框架都是用于3D目标检测的,二者各有优缺。OpenPCDet更轻量一些,更加专注于点云室外场景激光点云的目标检测任务,包含多种点云特征提取模型。mmdetection3d包含的内容更多,包含了图像、点云、多模态数据源的3D检测以及分割。mmdetection3d是一个比较新的模型结构,多个模块组装简单,同时支持多模态,就科研来说,更具有开发空间。 ...

Fzc_Ztt的博客 3115

【已解决】RuntimeError: Trying to backward through the graph a second time (or directly access saved tens

这个错误表明在你的代码中尝试对计算图进行第二次反向传播,或者在计算图中的某些保存的中间值已经被释放后,再次尝试访问它们。这个原因很简单,就是在进行训练的时候,由于是在下一次循环的时候前一次的计算图已经被释放了,所以下次计算就会出现问题,那怎么办呢?如果以上方法都没有解决问题,你可能需要检查你的训练循环和模型定义的详细情况,以确定在哪里出现了多次反向传播的问题。在训练循环结束时,确保你的模型和优化器都处于正确的状态。如果你在训练循环中有多个优化步骤,确保你在每个步骤中都使用了新的输入,或者使用了。

BetrayFree的博客 831

PyTorch Tensor 实战指南:7 类高频操作与 12 条 debug 铁律

Tensor 是 PyTorch 的核心数据载体,远不止是 NumPy 的替代品——它承载计算图构建、自动微分、GPU 调度与内存管理的全部语义。理解其创建机制(如 torch.tensor vs torch.Tensor)、设备迁移规则(to/cuda/empty_cache)、形状变换原理(view/reshape/permute)及梯度控制逻辑(detach/require_grad_/no_grad),是避免 RuntimeError、显存溢出和梯度消失的关键。尤其在工业级训练中,dtype 不匹配

shirlly 826

PyTorch自动求导机制详解:从原理到实战应用

自动微分是现代深度学习框架的核心技术,它通过反向模式自动微分算法,自动计算复杂函数关于输入变量的梯度。这一机制基于计算图动态记录所有运算操作,在反向传播时利用链式法则高效求解梯度,极大简化了神经网络训练中梯度计算的复杂性。其技术价值在于将开发者从繁琐的手动求导中解放出来,支持灵活的动态图构建,使得模型训练、参数优化和自定义层实现变得高效直观。在PyTorch中,autograd系统通过张量的requires_grad属性、backward()方法和计算图管理,广泛应用于神经网络训练、损失函数设计和梯度优化等

weixin_33787529的博客 370
上一篇: mayavi 显示bbox 和 朝向
下一篇: 2D / 3D IOU
THE@JOKER
博客等级 码龄10年 426粉丝 155原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值