Perfetto重大更新:一边分析trace一边看画面录屏结合功能

Perfetto 如何查看主线程哪些操作最耗时 使用 Perfetto,结合时间轴上的主线程 slice,查看调用栈和方法详细信息,可以帮助你定位主线程上的性能瓶颈。重点关注长时间执行的操作,并通过 CPU Profiler 进行线程状态的分析,找出具体的耗时原因,最终针对性地进行优化。 阅读详情

背景

大家在使用Perfetto分析相关trace时候,经常会分析SurfaceFlinger主线程每个vsync的相关slice,虽然也可以通过hwc的合成图层知道当前显示每一帧画面是啥,但是没有具体的与每一帧的画面的功能,大家都很希望可以在分析trace时候顺便有当前手机的运行画面可以结合起来看,类似winscope分析闪黑问题一样,这样就可以更加直观清晰分析一些卡顿显示等性能问题。
在这里插入图片描述针对这个需求Perfetto官方文档已经有这块trace中如何与录屏结合的说明了,所以本文就是摘录一下官方是如何手把手教你配置Perfetto抓取时候抓取录屏结合使用的功能。
(ps:但是马哥目前编译的最新aosp16 r4设备并没有成功,可能google公开版本中没有开放这个功能,有可以成功的记得可以留言告诉马哥哈)

屏幕录制 (Screen Recording)

android.display.video 数据源会记录 trace 采集期间每个物理屏幕显示的内容。Perfetto 将帧作为编码后的视频流存储在 trace 中,UI 会添加每个屏幕的时间线 track,在浏览器中解码它们。你可以悬停在 track 上预览帧、像播放视频一样回放帧,以及点击任意帧将其与下方的 track 对齐。


它会录制屏幕的实际内容,因此仅适用于 userdebug(debuggable)设备,任何包含此内容的 trace 都是敏感的:它精确地显示了屏幕上的内容。

本指南涵盖:

  • 工作原理及成本: 帧如何进入 trace,以及对设备的开销。
  • 采集屏幕视频:三种开启方式 — 设备端开关、录制页面以及可完全控制质量和大小的原始配置。
  • 查看屏幕视频:时间线 track、悬停预览帧以及保持时间线同步地回放采集内容。

工作原理及成本

在数据源启用期间,设备将每个屏幕显示的内容编码为视频流并存储在 trace 中 — 屏幕每次变化产生一帧 — UI 在浏览器中将其解码回来。这有两方面成本:

  • 编码器和 CPU 开销。 在 trace 运行期间,编码帧使用设备的视频编码器。在繁忙的屏幕上这会增加负载,并可能干扰你正在测量的时序。
  • Trace 大小。 视频流随分辨率和屏幕变化量而增长;下面的 scale 和 max_stream_size_bytes 选项可以控制其大小上限。

当数据源关闭时,零成本。

采集屏幕视频

有三种方式开启屏幕视频采集,从最简单到最多控制。

在设备上,使用 System Tracing

System Tracing 应用在 Trace settings 下有一个 Record display video 开关。启用它,然后像往常一样录制 trace — 采集会自动包含在内。这是在你手中的设备上最快的方式 — 无需编写配置。
在这里插入图片描述

从录制页面

打开 Perfetto UI 录制页面,在 Android probes 下找到 Display video frames,然后启用它。这会使用 producer 的默认设置将 android.display.video 数据源添加到生成的配置中。

在这里插入图片描述

从原始 trace 配置

要获得完全控制,自行编写配置。启用 android.display.video,并添加 display_video_config 来设置质量和大小。不带选项时,每个屏幕使用设备的默认设置:

data_sources {
  config {
    name: "android.display.video"
  }
}

添加 display_video_config 来调优采集。每个字段都是可选的;未设置或为零的字段使用 producer 默认值。

data_sources {
  config {
    name: "android.display.video"
    display_video_config {
      scale: 0.5
      format: FORMAT_H264
      key_frame_interval_secs: 2
      max_stream_size_bytes: 67108864  # 64 MiB per display
    }
  }
}
选项描述
scale采集前应用于每个屏幕分辨率的比例因子,例如 0.5 为一半大小或 0.25 为四分之一。较低的比例意味着更少的编码器负载和更小的 trace,但会牺牲细节。
formatFORMAT_H264(默认)或 FORMAT_HEVC。HEVC 在相同质量下产生更小的流,但设备必须支持 HEVC 编码才能采集,浏览器必须支持 HEVC 解码才能预览。
key_frame_interval_secs关键帧的发射频率。较小的值使定位更流畅但增大 trace;较大的值更紧凑但拖拽较慢。
max_stream_size_bytes每个屏幕的发送字节数上限。当屏幕达到上限时,其流被拆除(记录大小上限错误),而非无限增长。未设置时,设备默认每屏幕 256 MiB 的上限。

大小限制

屏幕视频每屏幕限制为 256 MiB,在两个独立的位置强制执行:

  • 在设备端,max_stream_size_bytes 限制每个流的发送量(默认 256 MiB;达到限制时记录大小上限错误)。
  • 独立地,trace_processor 在加载 trace 时丢弃每个流超过 256 MiB 的任何帧,因此仅提高设备端上限不会在 UI 中获得更多帧。

注意: 在长会话或高分辨率下,视频因此可能在 trace 结束之前停止。这两个限制都源自保存流的存储成本,而非根本性约束。如果它们妨碍到你,请在跟踪 issue perfetto#6609 上评论和点赞以便进行优先级排序。

查看屏幕视频

时间线 Track

包含屏幕视频的 trace 会显示一个 Video Frames 分组,每个屏幕有一个 track(对于手机,通常是一个 Built-in Screen)。Track 上的每个 slice 是一个采集的帧,标有帧号。该编号仅是采集帧的顺序计数器 — 与帧时间线中的 vsync ID 无关。

在这里插入图片描述

悬停预览帧

沿 track 移动指针即可预览帧。光标下的帧被解码并显示为该行上方的缩略图,因此你可以拖拽寻找想要的帧。

在这里插入图片描述

回放

点击一个帧打开其详情。面板左侧显示帧号和时间戳,右侧显示解码的 Preview,页眉中有播放控件:上一帧、播放/暂停、下一帧和播放速度选择器。按下播放,采集内容像视频一样播放:预览逐帧前进,时间线选择也随之前进,因此 UI 其余部分始终保持与屏幕上内容对齐。使用上一帧/下一帧按钮逐帧前进,或更改速度选择器以更慢(最低 0.1×)或更快(最高 2×)地回放。

在这里插入图片描述


Screen Recording

The android.display.video data source records what each physical display showed while a trace was being captured. Perfetto stores the frames as an encoded video stream inside the trace, and the UI adds a per-display timeline track that decodes them in the browser. You can hover the track to preview a frame, play the frames back like a video, and click any frame to line it up with the tracks below it.


It records the actual contents of the screen, so any trace that contains it is sensitive: it shows exactly what was on the display. On userdebug (debuggable) devices it is available out of the box. On user (production) builds it is disabled by default and must be unlocked with a system property first — see Prerequisite on user builds.

This guide covers:

  • How it works, and what it costs — how the frames get into the trace, and the overhead on the device.
  • Capturing display video: the property to set first on user builds, then the three ways to turn it on — the on-device toggle, the record page, and a raw config with full control over quality and size.
  • Viewing display video: the timeline track, hovering to preview a frame, and playing the capture back with the timeline kept in sync.

How it works, and what it costs

While the data source is enabled, the device encodes what each display shows into a video stream stored in the trace — one frame each time the screen changes — and the UI decodes it back in the browser. This has two costs:

  • Encoder and CPU overhead. Encoding frames uses the device’s video encoder while the trace runs. On a busy display this adds load and can perturb the timing you are measuring.
  • Trace size. The stream grows with resolution and with how much the screen changes; the scale and max_stream_size_bytes options below keep it bounded.

When the data source is off, it costs nothing.

Capturing display video

There are three ways to turn on display-video capture, from the simplest to the most control. On user builds there is also a one-time-per-boot property to set first — see the prerequisite below.

Prerequisite on user builds

On userdebug (debuggable) devices, display-video capture works out of the box, and you can skip this step. On user (production) builds it is disabled by default: unlock it first by setting a system property over ADB.

adb shell setprop debug.tracing_video_allowed true

This property is not persistent — it is cleared on the next reboot. After the device restarts you have to set it again before you can capture display video. Once it is set, capture works through any of the methods below: the on-device toggle, the record page, or a raw config.

On the device, with System Tracing

The System Tracing app has a Record display video toggle under Trace settings. Enable it, then record a trace as usual — the capture is included automatically. This is the quickest route on a device you are holding — no config to write.

(Illustration: The “Record display video” toggle in the System Tracing app’s Trace settings, enabled, described as “Captures encoded display frames (adds encoder overhead, can cause jank, and records screen contents)”)

From the record page

Open the Perfetto UI record page, find Display video frames under the Android probes, and enable it. This adds the android.display.video data source to the generated config with the producer’s default settings.

(Illustration: The Perfetto record page with “Android apps & svcs” selected in the sidebar; the “Display video frames” probe sits in the probe list, toggled off, captioned “Captures what each display showed during the trace.”)

From a raw trace config

For full control, write the config yourself. Enable android.display.video, and add a display_video_config to set quality and size. With no options, each display uses the device’s default settings:

data_sources {
  config {
    name: "android.display.video"
  }
}

Add a display_video_config to tune the capture. Every field is optional; an unset or zero field uses the producer default.

data_sources {
  config {
    name: "android.display.video"
    display_video_config {
      scale: 0.5
      format: FORMAT_H264
      key_frame_interval_secs: 2
      max_stream_size_bytes: 67108864  # 64 MiB per display
    }
  }
}
OptionDescription
scaleFactor applied to each display’s resolution before capture, e.g. 0.5 for half size or 0.25 for quarter. Lower scale means less encoder load and a smaller trace, at the cost of detail.
formatFORMAT_H264 (the default) or FORMAT_HEVC. HEVC produces a smaller stream at the same quality, but the device must support HEVC encoding to capture it and the browser must support HEVC decoding to preview it.
key_frame_interval_secsHow often a keyframe is emitted. Smaller values make seeking snappier but grow the trace; larger values are more compact but slower to scrub.
max_stream_size_bytesA per-display cap on emitted bytes. When a display hits it, its stream is torn down (a size-cap error) rather than growing without bound. Left unset, the device applies a default cap of 256 MiB per display.

Size limits

Display video is limited to 256 MiB per display, enforced in two separate places:

  • On the device, max_stream_size_bytes caps how much each stream emits (256 MiB by default; a size-cap error is recorded when it is hit).
  • Independently, trace_processor drops any frames beyond 256 MiB per stream when it loads the trace, so raising the on-device cap alone will not get you more frames in the UI.

Note: On a long session or at a high resolution, the video can therefore stop before the end of the trace. Both limits exist because of the memory cost of holding the stream, not a fundamental constraint. If they get in your way, comment on and upvote the tracking issue perfetto#6609 so it can be prioritised.

Viewing display video

The timeline track

A trace that contains display video shows a Video Frames group with one track per display (for a phone, typically a single Built-in Screen). Each slice on the track is one captured frame, labelled with a frame number. That number is just a sequential counter of captured frames — it has nothing to do with the vsync ids in the frame timeline.

(Illustration: The Perfetto timeline with the “Video Frames” group’s “Built-in Screen” track pinned to the top — a row of coloured slices labelled Frame 30, Frame 57, and so on — above the CPU scheduling tracks)

Hovering to preview a frame

Move the pointer along the track to preview frames. The frame under the cursor is decoded and shown as a thumbnail above the row, so you can scrub to find the frame you want.

(Illustration: Sweeping the cursor along the video-frames track; a decoded thumbnail of the frame under the cursor follows along above the row, updating as the cursor moves)

Playing back

Click a frame to open its details. The panel shows the frame number and timestamp on the left and a decoded Preview on the right, with playback controls in the header: previous frame, play/pause, next frame, and a playback-speed selector. Press play and the capture runs as a video: the preview advances through the frames and the timeline selection moves with it, so the rest of the UI stays lined up with what is on screen. Step one frame at a time with the previous/next buttons, or change the speed selector to play back slower (down to 0.1×) or faster (up to 2×).

(Illustration: Playing a display-video capture back with the video-frames track pinned at the top: in the details panel the decoded preview advances from the settings screen to the launcher while the frame number and timestamp update)


Source: Screen Recording - Perfetto Docs - https://perfetto.dev/docs/data-sources/video-frames

原文地址:
https://mp.weixin.qq.com/s/Er3MbxiygC4XzXcBXYWLiA

更多framework和性能优化实战,请关注下面“千里马学框架”

值得一看的Perfetto分析进阶 看到lock contention 片段,可以点击上边的monitor contention来查看当前对象锁竞争发生的调用栈,如下详情中显示当前对象锁被Owner (Binder:1754_16)持有,其持锁当前运行在serviceDoneExecuting (AMS.java 16426行),且当前等待该对象锁的线程已经有2个了;输入SQL语句,Enter,得到查询结果,显示在底部表格中,点击表格中的每一行,可以跳转到具体的slice中,根据trace上下文可以进一步分析问题。 阅读详情

相关推荐

Android性能分析新选择:从Simpleperf火焰图到Perfetto Trace的完整迁移指南

本文详细介绍了从Simpleperf火焰图迁移到Perfetto Trace的完整指南,帮助开发者掌握Android性能分析的新工具。Perfetto提供全系统事件追踪和微秒级时间精度,支持CPU调度、内存分配等多维度分析,大幅提升性能优化效率。文章对比了两种工具的核心差异,并提供了实战迁移案例和高级技巧。

weixin_30706691的博客 446

Trace 查看工具 perfetto 使用

谷歌浏览器 https://ui.perfetto.dev/,ts:单位 纳秒 ,1毫秒 = 1000000 纳秒。

三月的船长 1655

Perfetto和Graphics Profiler对比实战:手把手教你分析安卓系统trace文件

本文深入对比了Perfetto和Graphics Profiler在安卓系统性能分析中的优劣,提供了详细的实战指南。Perfetto适合系统级问题排查,而Graphics Profiler在GPU专项优化方面表现突出。文章还介绍了trace文件互操作技巧和高级调试方法,帮助开发者高效定位性能问题。

weixin_29264201的博客 421

如何使用Perfetto通过trace分析性能问题(五)——Trace-based metrics

trace processor, protobuf

m0_37999066的博客 2966

用perfetto精准定位Android卡顿根因的实战指南

在Android应用性能优化中,系统级trace分析是定位卡顿问题的关键手段。trace工具通过采集内核调度、CPU频率、Binder调用等底层数据,完整还原卡顿发生时的真实场景,让开发者不再依赖肉眼猜测。相比传统systrace,新一代trace系统在数据源、文件格式及分析能力上全面升级,支持SQL查询和自定义metric,使问题定位从经验驱动转向数据驱动。无论是偶现卡顿、竞品对比还是线上用户反馈,开发者都可以通过系统级trace快速锁定应用主线程、渲染线程或系统服务中的性能瓶颈。perfetto作为An

weixin_34293246的博客 364

Android15音频进阶之perfetto trace vs logcat(九十八)

本篇目的:Android15音频进阶之perfetto trace vs logcat需求:在Android和Linux性能分析中,逐渐离不开perfetto工具,之前分享的是使用perfetto直接加模块命令抓取trace。下面分享另一种方式来抓trace,perftto使用配置文件的方式,以及如何在perfetto中的trace对应Android的日志信息,这样即可以看到trace,又可以看到在时间轴上与之对应的Android日志信息。

Android系统攻城狮 1660

抓trace perfetto分析

prefetto 抓trace

b1tb1t的博客 1179

Android15音频进阶之perfetto抓trace四种方式及源码分析(一百二十)

本篇目的:Android15音频进阶之perfetto抓trace四种方式及源码分析。

Android系统攻城狮 2319

perfetto/systrace基础知识讲解-千里马android framework实战开发

一般perfetto看trace时候都会针对某一个进程进行查看其运行,因为perfetto/systrace都是以进程为单位进行划分的,每个进程又分为若干个线程,接下来又是主要看一个个的线程情况。比如,当一个进程向磁盘读写数据时,为了保证数据的一致性,在得到磁盘回复前,它是不能被其他进程或者中断打断的。这个部分和线程没啥关系,即不是说有单独一个线程在专门计数这个,可以理解为一个程序里面全局的一个变量值展示,比如在surfaceflinger的vsync时候就用到了。通常是低内存导致等待、各种各样的内核锁。

learnframework的博客 6017

Android14音频进阶之<进阶调试>:Perfetto定位系统音频问题(六十六)

本篇目的:Android14音频进阶之Perfetto如何定位系统音频问题接第六十五篇:混音线程MixerThread、FastMixer、FastThread、AudioMixer到底什么关系本篇来学习如何分析音频性能?以及如何在函数级别定位问题?其实本篇不只是用于音频,也可以延伸到其他模块。我们来借助一款系统和应用的分析工具:Perfetto!在Android9.0以前,其实用的是systrace工具分析。

Android系统攻城狮 2643

告别深度学习!用5个麦克风搞定多说话人分离:ReTM算法保姆级教程

本文详细介绍了ReTM算法,这是一种无需深度学习、仅需5个麦克风即可实现多说话人语音分离的创新信号处理方法。它通过估计相对传递矩阵,利用空间物理信息在混响环境中分离语音,具有数据需求低、计算复杂度小、无需先验几何信息等优势,特别适合嵌入式设备和资源受限场景。

desk3的博客 160

Perfetto分析进阶

一、Perfetto介绍Perfetto是AndroidQ中引入的全新下一代平台级跟踪工具,为Android、Linux和Chrome平台提供了一种通用的性能检测和跟踪分析工具集。其核心是引入了一种全新的用户空间到用户空间的跟踪协议,该协议基于protobuf序列化机制将抓取的数据填充到共享内存缓冲区,可用于获取平台内部的内置数据源(例如ftrace、atrace、logcat),也提供了SDK...

内核工匠 3万+

06-esp32-idf开发调试方法(内置JTAG,OpenOCD调试)

使用VS Code和ESP-IDF进行ESP32开发和调试 在我们搭建 **IDF** 框架后,**OpenOCD** 已经自动下载好了, 我们通过 **JTAG** 接口连接使用 **OpenOCD** 进行调试。而**ESP32**芯片中内置 了**JTAG** 电路,无需额外芯片即可调试,更加方便,所以这里我们讲解使用模块自带的usb-jtag接口进行调试。

宁子希的博客 1万+

Perfetto详细解析

Perfetto 是一个生产级的开源堆栈,用于提高性能 仪器和痕量分析。与 Systrace 不同,它提供数据源超集,可以用 protobuf 编码的二进制流形式记录任意长度的跟踪记录。可以将Perfetto理解为systrace的升级版,用在更新的平台、新图表展示更多的信息。

weixin_43700867的博客 7553

新能源车主必看:用高德API+充电站数据制作跨城出行充电规划工具(附完整代码)

本文为新能源车主提供了一份详细的跨城出行充电规划工具构建指南。通过整合高德地图API与充电站数据,手把手教你使用Python开发一个智能规划系统,可自动规划路线并推荐沿途充电站,有效缓解里程焦虑。文章包含完整代码、核心算法解析及可视化实现,帮助车主实现个性化、高效的出行规划。

tgb3456789的博客 900

Spatio-Temporal Graph Convolutional Networks: A Deep Learning Framework for Traffic Forecasting 论文笔记

Spatio-Temporal Graph Convolutional Networks: A Deep Learning Framework for Traffic Forecasting 论文笔记-----GCN在交通领域的应用(二) 一、论文翻译: 1、摘要: 及时准确地交通预测对于城市交通控制和指导具有至关重要的意义。由于交通流量的非线性和复杂性,传统的方法不能满足中长期预测任务的需求,并且往往会忽略时空数据的时间和空间依赖特性。在这篇论文中,为了处理在交通领域的时间序列预测问题...

cy_believ的博客 1916

性能分析--perfetto工具使用

摘要: 性能是IT开发的核心指标,涉及响应速度、处理能力等维度。手机性能由硬件(处理器、内存、存储、散热)和软件优化共同决定,需通过实际场景测试验证。Perfetto是Android平台的开源性能追踪工具,支持命令行或配置文件抓取系统级数据,并通过网页版(ui.perfetto.dev)可视化分析CPU调度、线程活动等。高级功能包括多文件对比、SQL查询及SDK自定义追踪。大文件处理需借助TraceProcessor本地加载。该工具能精准定位性能瓶颈,优化系统效率。

xx 2579

别再用LabelImg了!我手搓了一个C#“一站式”YOLO工具箱,标注训练推理全搞定

这个工具箱目前已经在两个小型产线项目中试用,反馈非常好。效率提升:原本需要 2 天完成的“数据准备 - 训练 - 验证”循环,现在缩短到了 2 小时。门槛降低:产线技术员经过 10 分钟培训,就能独立完成新产品的模型迭代。当然,它还有改进空间未来计划集成主动学习功能:自动筛选出置信度低的图片,推荐优先标注。支持多模型管理:方便在不同产品型号间快速切换。增加PLC 通信模块:直接在推理界面配置 IO 信号,实现真正的软硬联动。最后想说工具的本质是服务于人。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 442

Perfetto for linux-使用 Perfetto 分析调度问题

title: Perfetto for linux-使用 Perfetto 分析调度问题 date: 2020-11-21 22:40 author: gatieme tags: - scheduler - linux - debug categories: - scheduler thumbnail: blogexcerpt: Perfetto 工具是 Android 下一代全新的统一的 trace 收集和分析框架, 在 Android 9.0(API级别28)或更高版本的设备上, 可以使用 Syste.

OSKernelLAB(gatieme) 8106

YOLOv5改进策略|实战应用案例|YOLOv5苹果成熟度检测 ,准确率提升4.6%

苹果作为世界四⼤⽔果之⼀,富含多种维⽣素和矿物质,⼀直深受世界各地消费者的喜爱。据联 合国粮⻝及农业组织统计,全球⽔果产量中,苹果位列第⼆位,仅次于葡萄(贾等⼈,2020 )。然⽽,⼤多数苹果果实都是⼿⼯采摘的,这样的⽣产⽅法效率很低。此外,随着⼈⼝⽼龄化 和农村劳动⼒⼤量涌⼊城市,⽔果种植⾏业的劳动⼒成本也相应上升。所有这些因素都显着影响 着⽔果产品的市场竞争⼒。因此,实时⾼效采收苹果等⽔果,降低采收成本势在必⾏。基于机器 视觉的⽔果采摘机器⼈可以利⽤其信息感知来识别和采摘⽔果。

斌擎科技 2209

【Claude Code 源码解析教程】第4章:QueryEngine 查询引擎

本章深入解析 Claude Code 的核心引擎——QueryEngine,它是整个对话系统的"心脏",负责管理会话状态、消息处理流程和多轮对话支持。

rengang66的博客 270

Perfetto系统级性能分析实战:从抓trace到定位卡顿根因

系统性能分析是现代应用开发中绕不开的课题。当传统方法耗时统计无法解释卡顿问题时,需要借助事件追踪机制从内核调度、CPU占用、帧渲染等多维度还原真实执行链路。Perfetto作为基于ftrace的开放追踪平台,通过同一条时间轴串联应用行为与系统资源状态,让开发者能直观定位CPU抢占、掉帧、启动慢等疑难问题的根因。其Web UI与SQL查询能力进一步降低分析门槛,适用于启动耗时排查、UI掉帧归因、后台负载评估等典型场景。本文从trace抓取、UI读图到实战案例分析,系统梳理Perfetto的核心用法与常见误区,

weixin_34159110的博客 296

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

补充讲解perfetto/systrace的CPU Trace信息详解和抓取方法

前面讲解perfetto的查看信息时候,没有重点讲解cpu区域的内容,今天本文将补充讲解perfetto/systrace的CPU Trace信息详解,同时以前有讲解如何抓取开机时刻的perfetto/systrace的方法,但是也有同学反馈使用了对应config后,没有抓取到对应的cpu相关信息,本文针对上面两个知识来进行补充讲解。相比perfetto而言,systrace对cpu展示内容还多了,不过其实多的地方相对不那么核心,主要内容还是cpu的执行片段内容和cpu频率最重要。

learnframework的博客 2157

深度学习工具包 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")

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

android 性能分析工具(02)Perfetto

Perfetto 是 Android 10 中引入的全新平台级跟踪工具。这是适用于 Android、Linux 和 Chrome 的更加通用和复杂的开源跟踪项目。与 Systrace 不同,它提供数据源超集,可以用 protobuf 编码的二进制流形式记录任意长度的跟踪记录。总而言之,可以将Perfetto理解为sysyrace的升级版,用在更新的平台、新图表展示更多的信息。

wangdsh的博客 6585

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

重大更新:Perfetto有自己的智能体agent分析trace性能

确实在新版本Perfetto 59.1上面发现已经集成了AI分析的相关plugin,也有可以配置大模型的设置,但是国内一般配置大模型Deepseek,其实无法进行直接使用,大家可以使用其他模型看是否可以正常使用起来。

learnframework的博客 247
上一篇: google官方Perfetto 中使用 AI相关skill
下一篇: 重大更新:Perfetto中分析bitmap内存泄漏可以看到png图片
千里马学框架
博客等级 码龄6年 1万+粉丝 651原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千里马学框架

帮助你了,就请我喝杯咖啡

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值