cmake套路介绍

【Linux开发】OpenCV在ARM-linux上的移植过程遇到的问题4---共享库中嵌套库带路径【已解决】 【Linux开发】OpenCV在ARM-linux上的移植过程遇到的问题4—共享库中嵌套库带路径【已解决】标签:【Linux开发】紧接着上一篇,我居然又尝试了一下编译opencv,主要是因为由于交叉编译ARM-Linux,opencv,好像刚开始make install路径的问题,让我宿主机Ubuntu14.04上的opencv链接库被交叉编译库给冲掉,然后在宿主机上运行本机的Opencv程序时候居 阅读详情

历史

引用

CMake是为了解决美国国家医学图书馆出资的Visible Human Project专案下的Insight Segmentation and Registration Toolkit (ITK) 软件的跨平台建构的需求而创造出来的,其设计受到了Ken Martin开发的pcmaker所影响。pcmaker当初则是为了支援Visualization Toolkit这个开放源代码的三维图形和视觉系统才出现的,今日VTK也采用了CMake。在设计CMake之时,Kitware公司的Bill Hoffman采用了pcmaker的一些重要想法,加上更多他自己的点子,想把GNU建构系统的一些功能整合进来。CMake最初的实作是在2000年中作的,在2001年初有了急速的进展,许多改良是来自其他把CMake整合到自己的系统中的开发者,比方说,采用CMake作为建构环境的VXL社群就贡献了很多重要的功能,Brad King为了支援CABLE和GCC-XML这套自动包装工具也加了几项功能,奇异公司的研发部门则用在内部的测试系统DART,还有一些功能是为了让VTK可以过渡到CMake和支援(“美国Los Alamos国家实验室”&“洛斯阿拉莫斯国家实验室”)的Advanced Computing Lab的平行视觉系统ParaView而加的。

官网的教程

传送门
本章节将会按照官方网站里面提到的步骤来学习cmake的基本用法。

编译一个exe

CMakeLists.txt

cmake_minimum_required (VERSION 2.6)
project (Tutorial)
add_executable(Tutorial tutorial.cxx)

tutorial.cxx

// tutorial.cxx
#include <stdio.h>
int main (int argc, char *argv[])
{
  //...
  printf("hello");
  return 0;
}

使用版本号定义

cmake_minimum_required (VERSION 2.6)
project (Tutorial)
# The version number.
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
 
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
  "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
  "${PROJECT_BINARY_DIR}/TutorialConfig.h"
  )
 
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories("${PROJECT_BINARY_DIR}")
 
# add the executable
add_executable(Tutorial tutorial.cxx)

TutorialConfig.h.in文件中编写这个内容


// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@

最后将会生成代码TutorialConfig.h
在源码里面我们能很方便的使用

#include "TutorialConfig.h"
    fprintf(stdout,"%s Version %d.%d\n",
            argv[0],
            Tutorial_VERSION_MAJOR,
            Tutorial_VERSION_MINOR);

使用自己的lib库

# should we use our own math functions?
option (USE_MYMATH 
        "Use tutorial provided math implementation" ON) 
add_library(MathFunctions mysqrt.cxx)
include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
add_subdirectory (MathFunctions) 
 
# add the executable
add_executable (Tutorial tutorial.cxx)
target_link_libraries (Tutorial MathFunctions)

# add the MathFunctions library?
#
if (USE_MYMATH)
  include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
  add_subdirectory (MathFunctions)
  set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
endif (USE_MYMATH)
 
# add the executable
add_executable (Tutorial tutorial.cxx)
target_link_libraries (Tutorial  ${EXTRA_LIBS})
#ifdef USE_MYMATH
#include "MathFunctions.h"
#endif

#ifdef USE_MYMATH
  double outputValue = mysqrt(inputValue);
#else
  double outputValue = sqrt(inputValue);
#endif
#cmakedefine USE_MYMATH

安装与测试

将安装的文件拷贝到指定的目录中。

install (TARGETS MathFunctions DESTINATION bin)
install (FILES MathFunctions.h DESTINATION include)

# add the install targets
install (TARGETS Tutorial DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"        
         DESTINATION include)

先引入这个模块

include(CTest)

通过编写的宏来检查当前的测试是否能通过。

#define a macro to simplify adding tests, then use it
macro (do_test arg result)
  add_test (TutorialComp${arg} Tutorial ${arg})
  set_tests_properties (TutorialComp${arg}
    PROPERTIES PASS_REGULAR_EXPRESSION ${result})
endmacro (do_test)
 
# do a bunch of result based tests
do_test (25 "25 is 5")
do_test (-25 "-25 is 0")

平台检查

添加检查

# does this system provide the log and exp functions?
include (CheckFunctionExists)
check_function_exists (log HAVE_LOG)
check_function_exists (exp HAVE_EXP)

通过这个来检查当前平台是否存在log,exp函数,如果有将直接在代码里面使用系统的支持函数。
console

// does the platform provide exp and log functions?
#cmakedefine HAVE_LOG
#cmakedefine HAVE_EXP

代码

// if we have both log and exp then use them
#if defined (HAVE_LOG) && defined (HAVE_EXP)
  result = exp(log(x)*0.5);
#else // otherwise use an iterative approach
  . . .

自定义选项

用于制作条件打开某个功能。

# 设置一个OctSvr的开关,默认设置为OFF
option (OctSvr "OctSvr" OFF)
if (OctSvr)
      # 做一些开关内的事情。
endif (OctSvr)
# 在命令行中手动的打开或这关闭
cmake -DOctSvr=[ON|OFF(default)] 

开启c++ 17

// windows
    add_compile_options("/std:c++17")	
// linux
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ")

目录文件批量添加

file(GLOB pbc_SRC "3rd/pbc/src/*.h" "3rd/pbc/src/*.c" )

设置cmake工程依赖关系

add_subdirectory(common)
add_subdirectory(chuanqi_robot)
add_dependencies(chuanqi_robot common)

执行程序

添加一个生成文件和生成器

这个实例是编写了一个table生成的execute文件,生成一个开方的文件出来。然后通过cmake集成到编译过程中。
MakeTable.cxx文件中实现了一个可以生成table的一个程序

// A simple program that builds a sqrt table 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main (int argc, char *argv[])
{
  int i;
  double result;
 
  // make sure we have enough arguments
  if (argc < 2)
    {
    return 1;
    }
  
  // open the output file
  FILE *fout = fopen(argv[1],"w");
  if (!fout)
    {
    return 1;
    }
  
  // create a source file with a table of square roots
  fprintf(fout,"double sqrtTable[] = {\n");
  for (i = 0; i < 10; ++i)
    {
    result = sqrt(static_cast<double>(i));
    fprintf(fout,"%g,\n",result);
    }
 
  // close the table with a zero
  fprintf(fout,"0};\n");
  fclose(fout);
  return 0;
}

这里的cmakefile.txt文件中说明要如何生成这个MakeTable,之后添加了一个add_custom_command的命令,用于将一个table.h生成出来。
通过include_directories将本地目录加入到include搜索目录,并且在编译MathFunctions这个library库的时候,添加上Table.h的依赖。

# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
 
# add the command to generate the source code
add_custom_command (
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
  COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
  DEPENDS MakeTable
  )
 
# add the binary tree directory to the search path for 
# include files
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
 
# add the main library
add_library(MathFunctions mysqrt.cxx ${CMAKE_CURRENT_BINARY_DIR}/Table.h  )

现在完整的cmake

# CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
project (Tutorial)
include(CTest)
 
# The version number.
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
 
# does this system provide the log and exp functions?
include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
 
check_function_exists (log HAVE_LOG)
check_function_exists (exp HAVE_EXP)
 
# should we use our own math functions
option(USE_MYMATH 
  "Use tutorial provided math implementation" ON)
 
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
  "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
  "${PROJECT_BINARY_DIR}/TutorialConfig.h"
  )
 
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories ("${PROJECT_BINARY_DIR}")
 
# add the MathFunctions library?
if (USE_MYMATH)
  include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
  add_subdirectory (MathFunctions)
  set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
endif (USE_MYMATH)
 
# add the executable
add_executable (Tutorial tutorial.cxx)
target_link_libraries (Tutorial  ${EXTRA_LIBS})
 
# add the install targets
install (TARGETS Tutorial DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"        
         DESTINATION include)
 
# does the application run
add_test (TutorialRuns Tutorial 25)
 
# does the usage message work?
add_test (TutorialUsage Tutorial)
set_tests_properties (TutorialUsage
  PROPERTIES 
  PASS_REGULAR_EXPRESSION "Usage:.*number"
  )
 
 
#define a macro to simplify adding tests
macro (do_test arg result)
  add_test (TutorialComp${arg} Tutorial ${arg})
  set_tests_properties (TutorialComp${arg}
    PROPERTIES PASS_REGULAR_EXPRESSION ${result}
    )
endmacro (do_test)
 
# do a bunch of result based tests
do_test (4 "4 is 2")
do_test (9 "9 is 3")
do_test (5 "5 is 2.236")
do_test (7 "7 is 2.645")
do_test (25 "25 is 5")
do_test (-25 "-25 is 0")
do_test (0.0001 "0.0001 is 0.01")

btw: 今天发现在mac机器上dll文件换了个后缀,叫做*.dylib文件。_

手把手教你用Vivado的STARTUPE3原语驱动S25FL256S Flash(附完整Verilog代码) 本文详细介绍了如何利用Xilinx UltraScale+系列FPGA的STARTUPE3原语驱动S25FL256S SPI Flash,包括原语配置、SPI协议实现、状态机设计及调试技巧。通过完整的Verilog代码示例和性能优化建议,帮助开发者高效完成Flash通信解决方案的开发与集成。 阅读详情

相关推荐

STM32F0实现数字化SPWM纯正弦波逆变器

这个没啥好说的,搭电路的事。其核心思想是两边桥臂分别由两个180度相位差的正弦波与三角载波比较来控制,优点是在开关器件工作频率一样的情况下,输出PWM频率是单极性SPWM的2倍,能够明显减少谐波,因此只需要相对较小的电感和电容滤波器件就可以起到很好的滤波效果,提升了系统的性能,也精简了系统体积,降低了成本。而双极性pwm则是在整个正弦周期内,四只管子都在高频开关状态工作,对角线上的管子一起导通,另一对角线上管子互补导通,实际上只需要一路互补的PWM控制,负载上电压在正电压和负电压之间切换,不出现0v。

forlifefor的专栏 1万+

Erlang里的make

Erlang自带一个make工具  我们看一个例子  目录结构:  Java代码   --Emakefile   -include    --test.hrl   -src    --test.erl   -ebin   Emakefile:  Java代码   {'src/*', [{i, "include"}, {

铿锵玫瑰的专栏 1333

VTK的编译和部署,配合c++和visual studio2022,VTK开发环境的配置

在官网选择最新的版本下载之后进行解压,然后再里面创建build目录,方便后面使用cmake进行编译。

dz131lsq的博客 3223

CMake 发展概述

CMake 发展 历史 概述 链接 学习

qichengzong的博客 1476

从零开始深入理解 AI Agent(完整版)

AI Agent(智能体)是一个能够自主感知环境、做出决策、执行行动并记忆经验的智能系统。特性传统程序AI Agent决策方式固定逻辑(if-else)动态推理(LLM 思考)灵活性需要重新编程自然语言描述即可能力边界明确限定可通过工具扩展学习能力无可通过记忆积累经验│ 感知 │ ───→ │ 推理 │ ───→ │ 行动 │↑ │ ││ ↓ ││ 记忆 │ ←─── │ 反思 │ ←─────────┘感知(Perception)

qq_20096229的博客 757

《QGIS快速入门与应用基础》293:色带调整与透明设置

详细讲解了QGIS中遥感影像色带调整与透明设置的核心技术,帮助用户将遥感成果从基础合成提升到专业出图标准。主要内容包括: 色带精细化调整: 多波段真/假彩色合成的优化技巧(Gamma校正、色彩平衡、色阶端点校准) 单波段栅格数据的伪彩色规范设置(行业标准色带选择与分类方法) 透明设置: 研究区黑边/白边的消除方法 多图层叠加时的透明融合技巧 特定地物的差异化半透明显示 实用建议: 提供行业标准参数模板和效果对比图 标注新手操作红线和常见问题排查 强调符合遥感行业规范的可视化要求。

LuckyHanMo的博客 361

CMake的历史与编写规范(write once,run everywhere)、支持gdb调试工具、利用其中的CPack生成安装包

转载出处链接:http://www.hahack.com/codes/cmake/                          https://blog.youkuaiyun.com/u010122972/article/details/78216013 一、CMake的历史        由于各种make工具遵循不同的规范和标准,所执行的Makefile格式也不同,但如果想让软件跨平台,必须要保...

DestinyRen的博客 872

基于FPGA的7x7矩阵求逆verilog开发

up目录一、理论基础二、核心程序三、测试结果 矩阵求逆,即求矩阵的逆矩阵。矩阵是线性代数的主要内容,很多实际问题用矩阵的思想去解既简单又快捷。逆矩阵又是矩阵理论的很重要的内容,逆矩阵的求法自然也就成为线性代数研究的主要内容之一。设A是数域上的一个n阶方阵,若在相同数域上存在另一个n阶矩B,使得: AB=BA=E。 则我们称B是A的逆矩阵,而A则被称为可逆矩阵。其中,E为单位矩阵。典型的矩阵求逆方法有:利用定义求逆矩阵、初等变换法、伴随阵法、恒等变形法等。 逆矩阵的求法有多种,其中重要

FPGA/MATLAB学习教程/源码/项目合作开发 3898

使用Makefile编译Erlang

#配置选项,可以是DEBUG和RELEASE CONFIG ?= RELEASE #语言配置,可以是chs(简体中文)、cht(繁体中文)等等 Region ?= chs #源文件目录 SOURCE_DIR = ./src #文件包含目录 INCLUDE_DIR = -I ./include INCLUDE_DIR += -I ./src/config ...

weixin_33804582的博客 407

AI问数,智慧赋能:基于大语言模型的数据播报员应用实践探索

AI问数技术正在改变企业与数据交互的方式,它以自然语言为桥梁,让数据不再是少数专家的专利,而是成为所有业务人员的决策伙伴。这不仅是技术的创新,更是管理理念的革新。在数字化转型的关键阶段,企业应积极拥抱AI问数技术,通过降低数据使用门槛、提升数据利用效率、释放数据潜在价值,实现真正的数据驱动决策,为企业的高质量发展注入源源不断的智慧动能。AI问数,正在开启一个数据普惠的新时代。

getusushu的博客 64

YOLO11实战优化:暗光环境检测 | 引入Retinex增强模块与YOLO11联合训练,解决夜间/低照度场景抓拍痛点

本文探讨了暗光环境下目标检测的技术挑战与解决方案。研究发现,传统CNN模型在低照度条件下性能显著下降,主要由于光子数减少导致信噪比降低、目标特征被噪声淹没。针对这一问题,文章提出将可微分光照增强模块嵌入YOLO检测器的技术路线,重点分析了Retinexformer+YOLO11联合方案的优势。 文章对比了YOLO系列模型在暗光场景的表现,指出YOLO11凭借其C3k2模块、无锚检测头和多任务统一骨干网络,在低对比度图像特征提取方面优于前代产品。同时详细介绍了Retinexformer的理论基础和技术创新,包

2601_95807009的博客 206

嵌入式必备工具 CMake 的使用套路!

大家好,我是杂烩君。今天,我们就通过一个简单的,带你深度剖析嵌入式 CMake 的核心套路。

计算机毕业论文源码,学生个人网页制作html源码。贴近用户做网络推广和互联网优化。 1009

新系统申请软件著作权详细操作说明

今年八月底版权中心系统升级,新系统相对好用一些,至少不用再拿IE访问了,但是多了一项实名认证。下面介绍新系统的操作流程。 目录注册、登录和实名认证注册登录实名认证软件登记申请申请表填写鉴别材料身份证明文件权利归属证明文件其他材料提交材料变更登记 注册、登录和实名认证 首先访问版权中心系统:https://register.ccopyright.com.cn/login.html,如果老系统有账号直接登录即可,没有的话需要注册。 注册 点击注册按钮进入注册。 根据实际情况选择个人或单位,每个个人或单位只能在

Programming Talk 1万+

深入浅出CMake(三):find_package 添加依赖库

深入浅出CMake(一):基础篇 深入浅出CMake(二):基础语法及实现九九乘法表 有了前面两篇博文的基础,相信我们已经能够用 CMake 去编译比较简单的工程了,但是我们还差一步就可以应付大多数开发编译场景。 目前我们还不知道怎么样处理在工程中引入第三方库。 以 Unix 环境下的 c++ 代码工程为例。 加入工程要引入一个 libtest.so 动态库,源码是 hello.cpp。 如果用 ...

frank 的专栏 1万+

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

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

QtCreator对CMake的支持与局限-CMake快速上手小记

通过近期对QtCreator、CMake的试用,已经把现有的两组较为完备的项目迁移到CMake。在试用期间,还是遇到了一些坑,也对CMake的套路有了一些基本的认识。 本文 介绍通过在QtCreator下新建空项目,获得CMakeLists.txt模板的开始方法。 围绕CMake变量表的获取与查看,介绍如何快速用变量表完成判断。 评价目前Qt CMake与IDE的一些特点。 CMake与QMake的工程对照见我的工程taskBus和qplanetosm。 1. 快速开始一次迁移 1.1 从模板开始 对于

丁劲犇技术发布空间 4720

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

现代 CMake 模块化项目管理指南

如果模块 Carer 的头文件 Carer.h 虽然引用了其他模块中的 Animal 类,但是他里面并没有解引用 Animal,只有源文件 Carer.cpp 解引用了 Animal。如果不加,在你创建新文件时,myvar 不会自动更新,还是旧的那几个文件,可能出现 undefined symbol,需要重新运行 cmake -B build 才能更新。上图的案例中,我们在根目录下,创建了两个子项目 biology 和 pybmain,他们分别在各自的目录下有自己的 CMakeLists.txt。

喜欢打篮球的普通人 4036

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

1600_Cmake学习笔记_Cmake实践学习

我按照上面的例程信息抄了一遍尝试做测试调试,但是第一个方框画出来的地方应该在$符号之前加一个空格,否则至少我用的这个额cmake版本会报错。之前放弃学习的一个很重要的原因就是这个cmake的学习教程不是很好寻找,即使是找到的也有一些问题让人进行不下去。这一次,我去了找了其他人的教程来进行新的尝试,不过还是遇到了一些小情况。这样,一个简单的cmake的尝试的例程基本就结束了。前面看到的一个错误,其实在后面的文件中还是纠正了的。针对这里说的两个变量是对等的,我自己进行了修改测试,测试结果确认两个方式是对等的。

小灰笔记 931

cmake 安装_CMAKE安装(WINDOW UBUNTU IOS)

综述 CMake是一个跨平台的、开源的构建工具。cmake是makefile的上层工具,它们的目的正是为了产生可移植的makefile,并简化自己动手写makefile时的巨大工作量.目前很多开源的项目都可以通过CMake工具来轻松构建工程,例如博客之前分享的openHMD、hidapi、OSVR-Core等等,代码的分享者提供源代码和相应的Cmake配置文件,使用者就可以非常方便的在自己的电...

weixin_39632524的博客 191
上一篇: django操作mysql数据库&models的使用
下一篇: luajit FFI简单使用(1)
erlang_hell
博客等级 码龄14年 57粉丝 89原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值