【入门到实战】OpenHarmony南向子系统开发:热策略定制开发指南

鸿蒙OpenHarmony【热管控定制开发】子系统热管理 OpenHarmony默认提供了热管控的特性。设备在使用的过程中如果发热过多,则需要对发热的器件进行管控,如充电时电池温度过高,则需要对充电进行限制。但是管控动作在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。为此OpenHarmony提供了热管控的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。 阅读详情

往期鸿蒙5.0全套实战文章必看:(文中附带全栈鸿蒙5.0学习资料)


简介

OpenHarmony默认提供了热策略的特性。设备上发热的器件种类繁多,因此需要结合热等级和热场景,针对各类发热器件定制统一的管控策略。但是不同热等级下的管控动作在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。OpenHarmony提供了热策略的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。同时,出于安全性考虑,提供了热策略配置文件加解密的功能支持(可选)。

约束与限制

产品定制的配置路径,需要根据配置策略决定。本开发指导中的定制路径以/vendor进行举例,请开发者根据具体的产品配置策略,修改定制路径。

开发指导

搭建环境

设备要求:

标准系统开发板,如DAYU200/Hi3516DV300开源套件。

环境要求:

Linux调测环境,相关要求和配置可参考《快速入门》。

开发步骤

本文以DAYU200为例介绍热策略的定制方法。

  1. 在产品目录(/vendor/hihope/rk3568)下创建thermal文件夹。

  2. 参考默认热策略的配置文件夹创建目标文件夹,并安装到//vendor/hihope/rk3568/thermal,文件格式如下:

    profile
    ├── BUILD.gn
    ├── thermal_service_config.xml
    
  3. 参考默认热策略的配置文件夹中的thermal_service_config.xml编写定制的thermal_service_config.xml。包含热策略配置说明及定制后的热策略配置如下,以其中两个热等级为例:

    表1 config配置说明

    配置项名称配置项描述配置项类型配置项范围
    name定义热策略对应的传感器集合名称string对应热等级文档中定义的传感器集合名称
    level定义热策略对应的热等级int对应热等级文档中传感器集合下定义的热等级

    表2 配置项说明

    配置项名称配置项描述配置项类型配置项范围
    scene使用场景string对应热场景文档中定义的使用场景
    charge是否在充电int0(不在充电),1(正在充电)
    screen是否亮屏int0(灭屏),1(亮屏)

    表3 节点配置说明

    节点名称节点值类型节点值范围节点描述
    lcddouble0.00~1.00屏幕亮度的百分比(用浮点数表示)
    cpu_bigint根据产品定义CPU大核频率
    cpu_medint根据产品定义CPU中核频率
    cpu_litint根据产品定义CPU小核频率
    process_ctrlenum1:KILL_FG_PROCESS_APP
    2:KILL_BG_PROCESS_APP
    3:KILL_ALL_PROCESS_APP
    进程控制
    gpuint根据产品定义GPU频率
    thermallevelint对应config节点中的level热等级
    current_scint根据产品定义快充电流
    current_buckint根据产品定义慢充电流
    voltage_scint根据产品定义快充电压
    voltage_buckint根据产品定义慢充电压
    volumedouble0.00~1.00音量百分比(用浮点数表示)
    <policy>
        <config name="base_safe" level="1">
            <lcd>1.00</lcd>
            <lcd scene="cam">0.99</lcd>
            <lcd scene="call">0.98</lcd>
            <lcd scene="game">0.95</lcd>
            <cpu_big>1992000</cpu_big>
            <cpu_med>1991500</cpu_med>
            <cpu_lit>1991200</cpu_lit>
            <process_ctrl>3</process_ctrl>
            <cpu_big scene="cam" charge="1">1991800</cpu_big>
            <cpu_big scene="cam" charge="0">1991600</cpu_big>
            <gpu screen="0">524288</gpu>
            <gpu screen="1">512000</gpu>
            <thermallevel>1</thermallevel>
            <current_sc>1800</current_sc>
            <current_sc scene="cam">1200</current_sc>
            <current_buck>1200</current_buck>
            <voltage_sc>4000</voltage_sc>
            <voltage_buck>3000</voltage_buck>
            <volume>1.0</volume>
        </config>
    <policy>
        <config name="base_safe" level="2">
            <lcd>0.90</lcd>
            <lcd scene="cam">0.89</lcd>
            <lcd scene="call">0.88</lcd>
            <lcd scene="game">0.87</lcd>
            <cpu_big>1991000</cpu_big>
            <cpu_med>1990500</cpu_med>
            <cpu_lit>1990200</cpu_lit>
            <process_ctrl>2</process_ctrl>
            <cpu_big scene="cam" charge="1">1990800</cpu_big>
            <cpu_big scene="cam" charge="0">1990600</cpu_big>
            <gpu screen="0">499712</gpu>
            <gpu screen="1">487424</gpu>
            <thermallevel>2</thermallevel>
            <current_sc>1500</current_sc>
            <current_sc scene="cam">1000</current_sc>
            <current_buck>1000</current_buck>
            <voltage_sc>3000</voltage_sc>
            <voltage_buck>2000</voltage_buck>
            <volume>0.8</volume>
        </config>
    </policy>
    
  4. (可选)对热策略配置文件进行本地加密,同时配置解密方法。

    1. 开发者自行选择合适的加密工具对本地将编写好的thermal_service_config.xml进行加密。

    2. 开发者需要编写动态库libthermal_manager_ext.z.so并安装在文件系统中,动态库中包含解密接口getDecryptConfig的实现,程序将调用动态库中实现了的getDecryptConfig(在base/powermgr/thermal_manager/services/native/src/thermal_policy/thermal_srv_config_parser.cpp中)对配置文件进行解密,解密过程如下所示:

      bool ThermalSrvConfigParser::DecryptConfig(const std::string& path, std::string& result)
      {
          // 请开发者自行实现动态库libthermal_manager_ext.z.so
          void *handler = dlopen(THERMAL_CONFIG_LIBRARY_PATH, RTLD_LAZY);
          if (handler == nullptr) {
              THERMAL_HILOGE(COMP_SVC, "dlopen failed, reason : %{public}s", dlerror());
              return false;
          }
          // 请开发者根据所使用的工具自行实现解密接口getDecryptConfig
          Func getDecryptConfig = reinterpret_cast<Func>(dlsym(handler, GET_THERMAL_EXT_CONGIH_FUNC)); 
          if (getDecryptConfig == nullptr) {
              THERMAL_HILOGE(COMP_SVC, "find function %{public}s failed, reason : %{public}s",
                  GET_THERMAL_EXT_CONGIH_FUNC, dlerror());
              dlclose(handler);
              return false;
          }
          // 调用解密接口进行解密,将解密结果以字符串的形式存储在result中
          int32_t ret = getDecryptConfig(THERMAL_SERVICE_CONFIG_INDEX, result);
          if (ret != 0) {
              THERMAL_HILOGE(COMP_SVC, "decrypt config failed, ret:%{public}d", ret);
              dlclose(handler);
              return false;
          }
          dlclose(handler);
          return true;
      }
      c++
  5. 参考默认热策略配置文件夹中的BUILD.gn编写BUILD.gn文件,将thermal_service_config.xml打包到/vendor/etc/thermal_config目录下

    import("//build/ohos.gni")                      # 引用build/ohos.gni
    
    ohos_prebuilt_etc("thermal_service_config") {
        source = "thermal_service_config.xml"
        relative_install_dir = "thermal_config"
        install_images = [ chipset_base_dir ]       # 安装到vendor目录下的必要配置
        part_name = "product_rk3568"                # part_name暂定为product_rk3568,以实现后续编译,产品定制根据需要自行修改
    }
    
  6. 将编译目标添加到ohos.build的"module_list"中,例如:

    {
        "parts": {
            "product_rk3568": {
                "module_list": [
                    "//vendor/hihope/rk3568/default_app_config:default_app_config",
                    "//vendor/hihope/rk3568/image_conf:custom_image_conf",
                    "//vendor/hihope/rk3568/preinstall-config:preinstall-config",
                    "//vendor/hihope/rk3568/resourceschedule:resourceschedule",
                    "//vendor/hihope/rk3568/etc:product_etc_conf",
                    "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // 添加thermal_service_config的编译
                ]
            }
        },
        "subsystem": "product_hihope"
    }
    

    “//vendor/hihope/rk3568/thermal/”为文件夹路径,“profile”为创建的文件夹名字,“thermal_service_config”为编译目标。

  7. 参考《快速入门》编译定制版本,编译命令如下:

    ./build.sh --product-name rk3568 --ccache
    
  8. 将定制版本烧录到DAYU200开发板中。

调测验证

  1. 开机后,进入shell命令行:

    hdc shell
    
  2. 获取当前热策略信息。

    hidumper -s 3303 -a -p
    

    查看定制后的热策略结果如下:

    -------------------------------[ability]-------------------------------
    
    
    ----------------------------------ThermalService---------------------------------
    name: base_safe	level: 1
    actionName: lcd	actionValue: 1.00	isProp: 0
    actionName: lcd	actionValue: 0.99	scene: cam	isProp: 1
    actionName: lcd	actionValue: 0.98	scene: call	isProp: 1
    actionName: lcd	actionValue: 0.95	scene: game	isProp: 1
    actionName: cpu_big	actionValue: 1992000	isProp: 0
    actionName: cpu_med	actionValue: 1991500	isProp: 0
    actionName: cpu_lit	actionValue: 1991200	isProp: 0
    actionName: process_ctrl	actionValue: 3	isProp: 0
    actionName: cpu_big	actionValue: 1991800	charge: 1	scene: cam	isProp: 1
    actionName: cpu_big	actionValue: 1991600	charge: 0	scene: cam	isProp: 1
    actionName: gpu	actionValue: 524288	screen: 0	isProp: 1
    actionName: gpu	actionValue: 512000	screen: 1	isProp: 1
    actionName: thermallevel	actionValue: 1	isProp: 0
    actionName: current_sc	actionValue: 1800	isProp: 0
    actionName: current_sc	actionValue: 1200	scene: cam	isProp: 1
    actionName: current_buck	actionValue: 1200	isProp: 0
    actionName: voltage_sc	actionValue: 4000	isProp: 0
    actionName: voltage_buck	actionValue: 3000	isProp: 0
    actionName: volume	actionValue: 1.0	isProp: 0
    actionName: boost	actionValue: 1	isProp: 0
    
    level: 2
    actionName: lcd	actionValue: 0.90	isProp: 0
    actionName: lcd	actionValue: 0.89	scene: cam	isProp: 1
    actionName: lcd	actionValue: 0.88	scene: call	isProp: 1
    actionName: lcd	actionValue: 0.87	scene: game	isProp: 1
    actionName: cpu_big	actionValue: 1991000	isProp: 0
    actionName: cpu_med	actionValue: 1990500	isProp: 0
    actionName: cpu_lit	actionValue: 1990200	isProp: 0
    actionName: process_ctrl	actionValue: 2	isProp: 0
    actionName: cpu_big	actionValue: 1990800	charge: 1	scene: cam	isProp: 1
    actionName: cpu_big	actionValue: 1990600	charge: 0	scene: cam	isProp: 1
    actionName: gpu	actionValue: 499712	screen: 0	isProp: 1
    actionName: gpu	actionValue: 487424	screen: 1	isProp: 1
    actionName: thermallevel	actionValue: 2	isProp: 0
    actionName: current_sc	actionValue: 1500	isProp: 0
    actionName: current_sc	actionValue: 1000	scene: cam	isProp: 1
    actionName: current_buck	actionValue: 1000	isProp: 0
    actionName: voltage_sc	actionValue: 3000	isProp: 0
    actionName: voltage_buck	actionValue: 2000	isProp: 0
    actionName: volume	actionValue: 0.8	isProp: 0
    actionName: boost	actionValue: 1	isProp: 0

鸿蒙OpenHarmony【热策略定制开发】子系统热管理 OpenHarmony默认提供了热策略的特性。设备上发热的器件种类繁多,因此需要结合热等级和热场景,针对各类发热器件定制统一的管控策略。但是不同热等级下的管控动作在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。OpenHarmony提供了热策略的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。 阅读详情

相关推荐

Paypal开发者中心获取“ClientId”和“ClientSecret”参数

正式环境设置 1、登录到 paypal开发者中心 网址:https://developer.paypal.com/developer/ 点击右上角登录按钮登录 2、左侧栏 - 我的应用程序和凭证 - 点击“创建新应用” 新注册的paypal账号,需要进行邮箱验证,验证通过后,需要等待一段时间(或重新登录),才会出现相关设置项位置 验证邮箱通过后,点击创建新应用 3、按提示填写,保存创建应用 4、点击刚创建的应用进入应用详情页 5、应用详情页获得网站开发人员所需要的“ClientId”和“Client

龚清林的博客 1万+

OpenHarmony子系统开发 - 热管理(四),热策略定制开发指导

OpenHarmony默认提供了热策略的特性。设备上发热的器件种类繁多,因此需要结合热等级和热场景,针对各类发热器件定制统一的管控策略。但是不同热等级下的管控动作在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。OpenHarmony提供了热策略的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。同时,出于安全性考虑,提供了热策略配置文件加解密的功能支持(可选)。

__Benco的博客 1078

关于MII、RMII、GMII、RGMII、PHY、网络变压器、RJ45的硬件总结

文章目录前言一、网络传输结构及原理1.以太网的工作原理2.TCP/IP协议3.数据链路层(MAC)二、介质独立接口MII,RMII,GMII,RGMII1.MII(Media Independent interface)2.RMII(Reduced Media Independent Interface)3.GMII(Gigabit Medium Independent)4.RGMII(Reduced Gigabit Media Independent Interface)三、物理层芯片(PHY)二、使用步

weixin_44415816的博客 3万+

OpenHarmony子系统开发 - 热管理(一),充电空闲状态定制开发,热管控定制开发

OpenHarmony默认提供了热管控的特性。设备在使用的过程中如果发热过多,则需要对发热的器件进行管控,如充电时电池温度过高,则需要对充电进行限制。但是管控动作在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。为此OpenHarmony提供了热管控的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。

__Benco的博客 1351

从零开始:在Windows WSL中搭建Openfoam7+blastfoam2.0.0开发环境(避坑大全)

本文详细指导在Windows WSL中搭建OpenFOAM 7与BlastFOAM 2.0.0开发环境,重点解析了安装过程中的常见“坑点”,如编译模式不匹配导致的符号错误,并提供了从系统准备、软件部署到环境验证的完整解决方案,帮助开发者高效构建CFD与爆炸模拟开发平台。

stem5的博客 527

windows在使用ping 127.0.0.1时出现一般故障的解决方案

本文主要介绍了windows在使用ping 127.0.0.1时出现一般故障的解决方案,希望能对使用windows的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 7万+

OpenHarmony定制系统组合按键(二)

OpenHarmony 组合按键启动截屏或其他应用

mart!nhu的博客 710

uniapp - 解决App端报错reportJSException >>>> exception function:createInstanceContext, exception:white sc

uni-app,安卓Android,苹果ios,安卓app端,苹果App端,uniapp苹果安卓app,uniApp报错,reportJSException>>>>exceptionfunction:createInstanceContext,exception:whitescreencausecreateinstanceContextfailed,运行自定义基座时白屏,uniapp项目运行白屏reportJSException,检查没问题依旧报错,第三方库插件,组件,uniapp打包调试

🏆 前端领域优质创作者 1万+

OpenHarmony系统镜像定制:裁剪与预安装应用配置指南

你是否还在为智能设备固件体积过大而烦恼?是否希望出厂设备预装核心应用却不知从何下手?本文将系统讲解OpenHarmony系统镜像的裁剪优化与应用预安装全流程,帮助开发者解决存储空间占用、系统启动缓慢、定制化需求难以满足等痛点。 读完本文,你将获得: - 掌握轻量/小型/标准系统的差异化裁剪策略 - 学会通过组件配置文件精简系统镜像 - 理解应用预安装的两种实现机制 - 熟悉定制镜像的编译、验证与...

gitblog_00976的博客 1079

第14.10章 高翔博士最新开源框架Lightning-LM源码解读(十):在线定位run_loc_online涉及到的核心模块总结

本文对Lightning-LM激光SLAM定位框架进行了全面剖析。该框架是一个轻量高效的激光雷达建图与定位系统,支持3D SLAM、动态图层管理等功能。文章首先介绍了项目概况和源码结构,包括核心模块如定位系统(loc_system)、激光匹配(lidar_loc)和位姿图优化(pose_graph)等。接着详细解析了各模块的关键函数和运行流程,如数据接收处理、NDT匹配和位姿优化等。最后总结了学习该框架所需的C++知识要点,包括智能指针、多线程编程等现代C++特性。该分析为SLAM开发者提供了实用的架构参考

行知SLAM 805

HFSS实战项目——微带一分四功分器

呕心沥血保姆级教程!!!!手把手教会你做功分器,史上最详细步骤!!!

2401_87464239的博客 2680

【入门到实战】OpenHarmony南向子系统开发:热场景定制开发指南

OpenHarmony默认提供了热场景的特性。

Androidbye的博客 1063

STM32 USB键盘实现指南

在STM32上实现键盘功能可以通过USB HID(人机接口设备)协议来实现,使STM32设备能被计算机识别为标准键盘。通过上述步骤,您可以在STM32上实现一个功能完整的USB键盘。关键点包括:正确配置USB HID设备实现键盘矩阵扫描处理按键事件并生成HID报告优化按键响应和消抖处理添加额外功能如宏键和LED反馈这个实现可以作为基础,进一步扩展为游戏键盘、宏键盘或特殊输入设备。

suny8的专栏 975

【入门到实战】OpenHarmony南向子系统开发:热管控定制开发指南

OpenHarmony默认提供了热管控的特性。

Androidbye的博客 1000

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

【入门到实战】OpenHarmony南向子系统开发:热等级定制开发指南

OpenHarmony默认提供了热等级的特性。

Androidbye的博客 737

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

【入门到实战】OpenHarmony南向子系统开发:热日志定制开发指南

OpenHarmony默认提供了热日志的特性。

Androidbye的博客 963

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

【入门到实战】OpenHarmony南向子系统开发:热检测定制开发指南

OpenHarmony默认提供了热检测的特性。

Androidbye的博客 843

【入门到实战】OpenHarmony南向子系统开发:唤醒源定制开发指南

OpenHarmony支持多种唤醒源,如电源键、键盘、鼠标等,并提供了定制开启和关闭的方式。

Androidbye的博客 1179

【入门到实战】OpenHarmony南向子系统开发:电源默认休眠行为定制开发指南

不同设备的灭屏方式不相同......

Androidbye的博客 1125

【入门到实战】OpenHarmony南向子系统开发:电量等级定制开发指南

OpenHarmony默认提供了电量等级,根据当前的电量来定义系统统一的电量等级...

Androidbye的博客 1147

【入门到实战】OpenHarmony南向子系统开发:电池温度保护定制开发指南

OpenHarmony默认提供了电池温度保护的特性。

Androidbye的博客 1093

【入门到实战】OpenHarmony南向子系统开发:Seccomp策略使能开发指南

Seccomp(Secure computing mode)是Linux kernel支持的一种安全机制。

Androidbye的博客 814

【入门到实战】OpenHarmony南向子系统开发:电量与LED灯颜色的定制开发指南

OpenHarmony默认提供了电量与LED灯颜色的映射关系。

Androidbye的博客 749

OpenHarmony子系统开发 - 热管理(二),热检测定制开发,热等级定制开发

OpenHarmony默认提供了热等级的特性。不同的硬件设备发热量和所能承受的最大温度都不相同,因此需要根据不同器件的温度,来定义系统的热等级标准,从而清晰的表明当前设备的发热状态,给热策略提供输入。但是器件在不同温度下对应的热等级在不同的产品上规格是不同的,产品希望根据产品的设计规格来定制此特性。OpenHarmony提供了热等级的定制方式,产品定制开发者可根据产品的设计规格来定制这些特性。

__Benco的博客 1118

【入门到实战】OpenHarmony南向子系统开发:电源模式定制开发指南

OpenHarmony默认提供了电源模式(如正常模式、性能模式、省电模式、超级省电模式)的特性。

Androidbye的博客 951

【入门到实战】OpenHarmony南向子系统开发:充电空闲状态定制开发指南

OpenHarmony默认提供了充电空闲状态的特性。

Androidbye的博客 696
上一篇: 【入门到实战】OpenHarmony南向子系统开发:热日志定制开发指南
下一篇: 【入门到实战】OpenHarmony南向子系统开发:热场景定制开发指南
懂你的大海
博客等级 码龄6年 9049粉丝 1381原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值