opengl交叉编译

交叉编译openGL,Ubuntu20.04 to aarch64 (一) linux交叉编译openGL 阅读详情

I   xcb-proto编译

xcb-proto下载   https://xcb.freedesktop.org/dist/

这里使用的是1.14版本

配置  mips版本

ubuntu@ubuntu:~/Videos/OpenGL/xcb-proto-1.14$ CC=mips64el-linu-gcc CXX=mips64el-linux-g++ ./configure --prefix=/home/ubuntu/Videos/OpenGL/xcb-proto-1.14/loongson_install --host=mips-linux

ARM版,未验证

CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ ./configure --prefix=/home/ubuntu/Videos/OpenGL/xcb-proto-1.14/arm_install  --host=arm-linux

安装

make 

make install

路径设置,不然下面的libxcb找不到

export PKG_CONFIG_PATH=/home/ubuntu/Videos/OpenGL/xcb-proto-1.14/loongson_install/lib/pkgconfig
 

libX11

Index of /archive/individual/lib

这里使用的是

II libxcb

下载  Index of /dist (xcb.freedesktop.org)

这里使用的是1.14版本

配置mips版本

 CC=mips64el-linux-gcc CXX=mips64el-linux-g++ ./configure --prefix=/home/ubuntu/Videos/OpenGL/libxcb-1.14/loongson_install --host=mips-linux

编译安装

make 

make install

III  libX11

下载

Index of /archive/individual/lib

配置

 ./configure --prefix=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install --host=mips64el-linux
 

报错

ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ echo "xorg_cv_malloc0_returns_null=yes" > arm-linux.cache
ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ ./configure --prefix=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install --host=mips64el-linux --cache-file=arm-linux.cache

 配置成功

编译make -j8 ,报错

 添加其他库文件

Index of /archive/individual/proto (xorg.freedesktop.org)

这里使用的是xproto-7.0.31.tar.gz

拷贝到libx11源码目录下并解压

配置并安装

./configure --prefix=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install --host=mips64el-linux
make 
make install

之后编译libX11

新加配置

ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ export PREFIX=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install
ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ 

之后配置编译

ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ echo "xorg_cv_malloc0_returns_null=yes" > arm-linux.cache
ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ ./configure --prefix=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install --host=mips64el-linux --cache-file=arm-linux.cache
之后make

这次报错

参考,索性一次把改下的包下完

(6条消息) 交叉编译libX11_OneSea的专栏-CSDN博客_交叉编译libx11

  下载https://xorg.freedesktop.org/archive/individual/lib/xtrans-1.4.0.tar.gz

  网址Index of /archive/individual/lib (xorg.freedesktop.org)

配置编译安装同 xproto-7.0.31.tar.gz ,报错

下载kbproto-1.0.6.tar.bz2http://mirror2.openwrt.org/sources/kbproto-1.0.4.tar.bz2

配置编译安装同 xproto-7.0.31.tar.gz ,这个没有make ,直接make isntall ,可能会有问题,暂时报错

下载http://mirror2.openwrt.org/sources/inputproto-2.0.tar.bz2kbproto-1.0.6.tar.bz2

配置编译安装同 xproto-7.0.31.tar.gz ,这个没有make ,直接make isntall ,可能会有问题,暂时报错

下载 https://www.x.org/releases/individual/lib/libxcb-1.14.tar.gz

 配置编译安装同 xproto-7.0.31.tar.gz ,暂时报错

出现配置问题

 sudo apt-get install doxygen

 因为目前ubuntu 的支持到1.13.1 ,所以重新下个

https://www.x.org/releases/individual/xcb/libxcb-1.13.1.tar.gz

sudo apt-get install xsltproc

sudo apt-get install xcb-proto

配置OK ,编译问题

解决sudo apt-get install python-xcbgen

下载

 https://www.x.org/releases/individual/lib/libXau-1.0.9.tar.gz

 配置编译安装同 xproto-7.0.31.tar.gz ,重新编译libxcb

ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3/libxcb-1.13.1$ export PREFIX=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install
ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3/libxcb-1.13.1$ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3/libxcb-1.13.1$ ./configure --prefix=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install --host=mips64el-linux

编译安装 make &&make install

重新编译libX11,报错

下载

https://xorg.freedesktop.org/archive/individual/proto/xorgproto-2021.5.tar.gz

 配置编译安装同 xproto-7.0.31.tar.gz ,编译libX11

ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ echo "xorg_cv_malloc0_returns_null=yes" > arm-linux.cache
ubuntu@ubuntu:~/Videos/OpenGL/libX11-1.7.3$ ./configure --prefix=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install --host=mips64el-linux  --cache-file=arm-linux.cache CPPFLAGS="-I/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install/include" LDFLAGS="-L/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install/lib"

之后make && make install

IV  libDrm

下载

https://dri.freedesktop.org/libdrm/libdrm-2.4.100.tar.gz

配置编译安装

CC=mips64el-linux-gcc CXX=mips64el-linux-g++ ./configure --prefix=/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install  --disable-amdgpu  --disable-intel   --target=mips-linux --host=mips-linux --disable-cairo-tests 

之后make && make install

V MESA

下载

https://archive.mesa3d.org//mesa-20.0.1.tar.xz

配置编译安装

设置环境变量


export PREFIX=/home/ubuntu/Videos/OpenGL/libX11-1.7.3/loongson_install

export HOST=mips64el-linux

export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/lib/pkgconfig:/home/ubuntu/Videos/OpenGL/xcb-proto-1.14/loongson_install/lib/pkgconfig


export CXX=mips64el-linux-g++


export CC=mips64el-linux-gcc

配置

./configure --prefix=/home/ubuntu/Videos/OpenGL/mesa-19.0.0/loongson_install --target=mips-linux --host=mips-linux --enable-gles2 --enable-gles1 --disable-glx --disable-egl --disable-dri --enable-shared-glapi  --with-dri-drivers=swrast  LIBDRM_CFLAGS="-I/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/include
 -I/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/include/libdrm" LIBDRM_LIBS="-L/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/lib" --enable-autotools --enable-dri --disable-dependency-tracking



ubuntu@ubuntu:~/Videos/OpenGL/mesa-19.0.0$ ./configure --prefix=/home/ubuntu/Videos/OpenGL/mesa-19.0.0/loongson_install --target=mips-linux --host=mips-linux --enable-gles2 --enable-gles1 --disable-glx --disable-egl --disable-dri --enable-shared-glapi  --with-dri-drivers=swrast  LIBDRM_CFLAGS="-I/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/include:/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/include/libdrm" LIBDRM_LIBS="-L/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/lib" --enable-autotools --enable-dri --disable-dependency-tracking



编译安装

make 

报错

 下载

http://www.zlib.net/zlib-1.2.11.tar.gz

配置编译安装

export CC=mips64el-linux-gcc

./configure --prefix=/home/ubuntu/Videos/OpenGL/zlib-1.2.11/loongson_install

make

make install

修改配置文件,继续编译

./configure --prefix=/home/ubuntu/Videos/OpenGL/mesa-19.0.0/loongson_install --target=mips-linux --host=mips-linux --enable-gles2 --enable-gles1 --disable-glx --disable-egl --disable-dri --enable-shared-glapi  --with-dri-drivers=swrast  LIBDRM_CFLAGS="-I/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/include:/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/include/libdrm:/home/ubuntu/Videos/OpenGL/zlib-1.2.11/loongson_install/include" LIBDRM_LIBS="-L/home/ubuntu/Videos/OpenGL/libdrm-2.4.100/loongson_install/lib:/home/ubuntu/Videos/OpenGL/zlib-1.2.11/loongson_install/lib" --enable-autotools --enable-dri --disable-dependency-tracking

报错

 

交叉编译Qt5.12.8附带编译opengl 最近有个项目使用Qt5的ARM64版,有一种方法是直接在板子上安装Qt5,这种方法最简单,但是板子效率低一些,编译慢,画面也不太流畅所以才切换到交叉编译方向来。这篇文章基于Ubuntu-20.04编译,板子的系统也是20.04,接下来我会给出我的编译心得,包括一些注意事项,请仔细查看,能少走不少弯路。工具:aarch64-linux-gnu-91、本身并不难,找到诀窍才是重要的,选不对版本和工具链够头疼的,还是那句话:尽量维持环境一致性。 阅读详情

相关推荐

Qt5.14.2 + opengl 交叉编译移植至Jetson Nano(补充)

这步非常重要,将第五步执行完之后到你的开发机器(我的是ubuntu20.04的虚拟机)看看相应的目录有没有这些软链接,如果没有在相应文件再执行一次。最重要:开发机器只负责编译,而文件系统负责在开发机器上提供jetson nano上的一些库,安装库要在jetson nano上。如果一次性安装出错就一个一个的安装(一定要在jetson nano安装)。执行这个指令后我发现没有aarch64-linux-gnu-g++,注:在开发机器(ubuntu20.04)上安装。不要忘了修复因为同步而损坏的链接文件,要在。

qq_33262177的博客 1100

Qt嵌入式解决方案(Qt5.14.2 + opengl 交叉编译移植至Jetson Nano 详细步骤)

在我需要将Qt应用程序运行到嵌入式arm linux平台上时,我了解到了两种方案: Qt for Device Creation + Boot to Qt,这项技术相当诱人,虽然只有商业版Qt能够使用,但用了这么久的开源版本Qt,为其适当的付费也未尝不可;但是当我在Qt的官网上了解到公司商用Qt需要留下资料协商定价后,我就打消了这个念头,因为这充满了未知,谁也不知道他们想要如何定价,在Qt的官网上还有着相当嘲讽的广告: 交叉编译Qt源码,移植至arm linux,网上大部分资料都是较为老的Qt版本,.

为啥不吃肉捏 的博客 1万+

QT5.5.1 + OpenGL 交叉编译

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34315665的博客 6260

树莓派Tools交叉编译OpenGL(mesa-12.0.5)

以下shell命令都是在root权限下执行的。得按照顺序来,不然会报找不到包或者一些文件找不到这些话,交叉编译玩多了,自己翻来覆去,整多了后其实也就融会贯通了,有耐心就行。宗旨就是你得让它们找到的到对应文件。一般要么在环境变量里去pkg-config的库文件路径,要么就是在configure时指定下CPPFLAGS、LDFLAGS路径。要么提前aptitude install一些库。 由于博主是在做一个体系 的介绍,如果想要知道前情(一些配置环境)可以自行去主页查找之前的博客。下面的博客含有了树莓派交叉工

jiugeshao的专栏 4097

QT5+OpenGL es2 + eglfs交叉编译安装(RK3399)

最近由于项目的需要,需要在aarch64 Ubuntu16.04中安装QT5,本来系统中自带了一个qt5,奈何项目要求必须是qt5.12的版本并且需要包含opengl和eglfs的库,所以只能重新移植QT5.12到开发板中,下面把移植过程记录下。 下载QT5源码 下载地址:https://download.qt.io/archive/qt/ 找到自己需要的版本进行下载。 图中标出来的就是源码下载链接。随便下载哪一个都行。下载后放入ubuntu(我用的Ubuntu 16.04)系统中进行解压。 解压

xuesong10210的博客 2万+

交叉编译的隐形陷阱:为何你的QT+OpenGL在RK3568上依然卡顿?

本文深入分析RK3568平台上QT+OpenGL应用卡顿的根本原因,揭示交叉编译中的隐形陷阱。从系统环境完整性校验、GPU驱动与EGL配置匹配、编译选项优化到系统性性能诊断,提供全方位解决方案,帮助开发者彻底解决QML动画卡顿问题,提升渲染性能。

828

arm交叉编译qt应用中含opengl问题解决

问题是采用正点原子方案中,用虚拟机交叉编译含opengl的qt程序会出现编译失败问题,因为正点原子中的交叉编译qt源码时没有编opengl。

轩辕霸天L 328

交叉编译openGL,Ubuntu20.04 to aarch64 (三)

linux交叉编译openGL

qq_33856381的博客 1178

linux opengl配置编译,在Linux上设置OpenGL的gtkmm的和交叉编译

我开始学习OpenGL和我不知道,如何将它安放(Ubuntu的)Linux操作系统。在Linux上设置OpenGL的gtkmm的和交叉编译我认为这可能是一个办法:OpenGL是唯一一个图形语言规范(或接口),并正确地使用它,我要下载一些库(用于特定OS)是工具的OpenGL规范。经过长期的搜索并从多个来源,我发现了梅萨的3D图形库将是最适合我。我还发现了SDL(简单直接层)库,但它似乎是图形身边所...

weixin_30586369的博客 498

RK3588 Qt源码交叉编译实战:集成OpenGL ES2图形加速

本文详细介绍了在RK3588平台上进行Qt源码交叉编译并集成OpenGL ES2图形加速的实战步骤。从环境准备、源码获取到系统根目录配置,再到关键configure参数解析和qmake.conf定制,提供了全面的技术指导。文章还包含编译安装技巧、常见问题排查及性能优化建议,帮助开发者高效实现图形加速功能。

weixin_30374009的博客 437

Qt OpenGL交叉编译测试案例:QOpenGLWidget功能验证

Qt是一套跨平台的C++应用程序框架,它用于开发具有图形用户界面(GUI)的应用程序,同时也支持非GUI程序,如命令行工具和服务器。Qt框架提供了一整套的工具和库,让开发者能够高效地进行软件开发。它广泛应用于软件开发领域,特别是在桌面和嵌入式系统的应用程序开发中。在Qt框架中,所有的GUI元素都是通过称为“小部件”的对象构成的。这些小部件可以独立使用,也可以组合成复杂的用户界面。Qt还具有强大的网络、数据库和多线程功能,使得开发者可以创建从简单的命令行工具到复杂的多线程网络应用程序的各个层级的应用。

weixin_42451850的博客 1111

Ubuntu下使用树莓派交叉编译工具编译QT(带OpenGL)及在树莓派上进行验证

主要是为了解决前面博客最后图片不能显示问题,所以博主决定沉下心来先把一些基础知识重新整理下,所以才有了前面三篇博客: Ubuntu下的基本知识点(一)_jiugeshao的专栏-CSDN博客 Ubuntu下的基本知识点(二)_jiugeshao的专栏-CSDN博客 Ubuntu下源码编译OpenCV静态库及使用(勾选WITH_QT)_jiugeshao的专栏-CSDN博客 在此基础上,博主继续做了多次尝试,终于解决了此问题。过程中也参考stack Overflow上的解决方法,然而并没有什么作用,其

jiugeshao的专栏 9056

飞腾X100芯片GPU状态查询

本文档对在linux系统下查看X100芯片GPU状态信息进行说明,可以帮助大家了解芯片的实时工作状态。

乌拉大喵喵 2823

qt 交叉编译后 无libqxcb_QT5.5.1 + OpenGL 交叉编译

概述要使用Qt的quick相关功能则需要编译openglopengl使用的是mesa,其依赖 libdrm,libxcb,libudevlibxcb依赖 x11,xcb-protolibxcb 编译libdrm编译CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ ./configure --prefix=/home/huey/...

weixin_39640090的博客 2456

DataHub 架构设计与核心工作原理

DataHub 是一个第三代数据目录系统,专为现代数据栈设计,支持数据发现、协作、治理和端到端可观测性。其架构采用模型优先的设计理念,注重不同工具和系统之间的互操作性。

北斗云的博客 1232

看完这篇爽文我终于学会了示波器(一)

示波器基础篇的介绍,希望对你有用,下次分享一下如何测试。

qq_45508321的博客 978

RK3588 交叉编译QT 源码 增加opengl功能

1 #平台aarch64 编译工具 如:aarch64-none-linux-gnu-gcc。qt5

m0_60496831的博客 1821

提示deepseek生成完整的json用于对接外部API

通过精准的提示词设计(字段过滤、格式约束)、动态验证机制(自检与修正)和官方模板参考,可有效确保DeepSeek生成的JSON纯净无冗余。

神棍之路 2317

从GLES3头文件缺失看Qt交叉编译:如何正确配置OpenGL ES开发环境

本文针对Qt交叉编译中常见的GLES3头文件缺失错误,深入剖析了其根源在于编译环境与目标环境不匹配。文章系统性地介绍了如何通过构建完整的嵌入式图形开发套件(如Mali GPU SDK)并将其集成到sysroot中,以及如何正确配置Qt以支持OpenGL ES,从而搭建健壮、可维护的交叉编译环境,从根本上解决此类问题。

meat5的博客 461

abaqus wcm插件下载_Abaqus随机短纤维增强复合材料建模插件

文末附Abaqus随机短纤维增强复合材料建模插件下载链接前言短纤维增强复合材料相对于长纤维增强复合材料来说更容易制备,且短纤维的填充性能略有改善,可制造复杂产品,广泛应用于车辆、航空航天、建筑等行业,对短纤维增强复合材料进行细观力学分析,可对其宏观力学性能进行预测、分析破坏机理等。接下来对随机短纤维增强复合材料建模插件进行介绍。NO.1 【算法简介】难点一:此插件核心在于判断生成的纤维是...

weixin_39974882的博客 2837

华为OD机考双机位C卷 - 螺旋数字矩阵 (Java & Python& JS & C/C++ & GO )

华为OD机考双机位C卷 - 数字螺旋矩阵(OD上机考试双机位C卷)。提供在线OJ刷题。Java、C++、Python、GO语言、C语言、JavaScript题解,并提供完整思路讲解。

算法大师! 3233

RK3568嵌入式Qt交叉编译实战:解决QML卡顿与OpenGL ES2集成

本文详细介绍了在RK3568平台上通过交叉编译集成OpenGL ES2支持以解决QML卡顿问题的实战方法。内容包括环境配置、sysroot构建、Qt编译优化及部署测试,帮助开发者充分利用Mali-G52 GPU硬件加速,显著提升QML界面流畅度。

ruby5的博客 772

C#客户端对接工厂MES的方法

本文介绍了使用C#实现WebApi客户端与工厂MES系统交互的方法。主要包括四个步骤:1)配置工控机IP地址;2)获取服务器URL;3)创建HttpHelper帮助类实现单例模式HttpClient,提供异步POST请求方法;4)通过实例化帮助类实现设备状态数据的JSON格式发送与接收。该方案采用异步通信方式,支持超时处理,能够满足大多数MES系统交互需求,帮助工程师快速完成设备与MES系统的数据对接。文中给出了核心代码片段和完整的数据交互流程示例。

weixin_39832501的博客 269

交叉编译Mesa,X11lib,Qt opengl 补充

对交叉编译Mesa,X11lib,Qt opengl的补充,由于zh5301这位同行在讨论这个交叉编译,他交叉编译qt的时候带有xcb,那么我将我的交叉编译所有的库所需的文件全部发上来,由于我交叉编译的时候考虑到要用opengl、xcb、xserver等,故而我一次性交叉编译了以下的库,方便配置qt的时候根据需要选择,附下: . ├── app │ ├── bdftopcf-1.0.3

MKNDG的专栏 5552

078、镜头阴影校正:LSC算法原理与标定优化

文章摘要 镜头阴影校正(LSC)是手机影像系统中的关键技术,用于解决镜头渐晕效应导致的画面边缘暗角问题。本文详细分析了LSC算法的核心原理,包括非均匀网格划分、双线性插值等关键技术点,并揭示了标定流程中的常见陷阱(光源均匀性、灰卡反射特性、温度漂移)。文章还深入探讨了增益计算的工程实现细节,以及实际调优中的关键考量因素(色差校正、动态场景适应等)。作者结合15年经验,给出了包括验证方法、网格参数设计、产线标定等实用性建议,强调LSC算法应与光学设计协同优化,才能达到最佳效果。

sundong_81的博客 44

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

QT笔记--嵌入式QT交叉编译与移植(含OpenGL ES2)

本文记录了QT并移植到开发板的过程,并在虚拟机上用QTcreater 开发程序,到开发板上运行。其中重点解决了一些过程中的BUG和坑。

szembed的博客 4395

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

上一篇: ffmpeg交叉编译
下一篇: TCP/UDP/HTTP
逆商
博客等级 码龄13年 162粉丝 77原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址