第九章:系统设计

手把手教你完成简单C++课设——创新活动管理系统(超详细) 阅读详情

第九章:系统设计


C++ 在系统设计领域具有广泛应用,其性能和灵活性使其在嵌入式系统、操作系统开发、高性能服务器以及分布式系统中占据核心地位。本章将介绍 C++ 在系统设计中的主要应用场景、设计原则以及具体的实现案例。


9.1 系统设计基础
  • 什么是系统设计

    • 系统设计涉及从需求分析到最终实现的完整过程,涵盖架构设计、模块划分、性能优化和扩展性设计。
  • C++ 在系统设计中的优势

    • 精确的内存管理:通过手动控制提升效率。
    • 接近底层:支持内联汇编和硬件接口开发。
    • 丰富的库生态:适用于并发、网络和分布式场景。
  • 系统设计的关键原则

    • 模块化:通过分而治之的方法减少复杂性。
    • 高内聚低耦合:增强模块的独立性和复用性。
    • 可扩展性:保证系统能适应需求变化。
    • 性能优先:在设计中避免过度抽象对性能的影响。

9.2 嵌入式系统设计

嵌入式系统通常在资源有限的硬件上运行,对代码效率有严格要求。

  • 硬件接口编程

    • 使用 C++ 操作硬件寄存器:
      volatile uint8_t* port = reinterpret_cast<volatile uint8_t*>(0x4000);
      *port |= (1 << 3);  // 设置第3位
      
  • 实时系统开发

    • 利用 std::chrono 和计时器实现实时任务:
      while (true) {
          auto start = std::chrono::high_resolution_clock::now();
          performTask();
          auto end = std::chrono::high_resolution_clock::now();
          std::this_thread::sleep_for(std::chrono::milliseconds(10) - (end - start));
      }
      
  • 优化技巧

    • 使用固定大小数组替代动态分配。
    • 减少全局变量,避免数据竞争。

9.3 高性能服务器设计

C++ 在高性能服务器设计中广泛应用,尤其在高并发和低延迟的场景下。

  • 多线程服务器

    • 使用线程池处理客户端请求:
      #include <thread>
      #include <queue>
      #include <condition_variable>
      
      std::queue<std::function<void()>> taskQueue;
      std::mutex mtx;
      std::condition_variable cv;
      
      void workerThread() {
          while (true) {
              std::function<void()> task;
              {
                  std::unique_lock<std::mutex> lock(mtx);
                  cv.wait(lock, [] { return !taskQueue.empty(); });
                  task = std::move(taskQueue.front());
                  taskQueue.pop();
              }
              task();
          }
      }
      
      void startServer() {
          std::vector<std::thread> threadPool;
          for (int i = 0; i < 4; ++i) {
              threadPool.emplace_back(workerThread);
          }
      }
      
  • 事件驱动模型

    • 使用 epoll 或 Boost.Asio 实现高效的事件驱动机制。
    • 示例:Boost.Asio 异步模型:
      boost::asio::io_service io;
      boost::asio::ip::tcp::acceptor acceptor(io, tcp::endpoint(tcp::v4(), 8080));
      boost::asio::ip::tcp::socket socket(io);
      
      void handleAccept() {
          // 处理新连接
      }
      
      acceptor.async_accept(socket, [](boost::system::error_code ec) {
          if (!ec) handleAccept();
      });
      io.run();
      
  • 性能优化

    • 使用内存池减少动态分配的开销。
    • 利用零拷贝(Zero-Copy)技术优化数据传输。

9.4 分布式系统设计

分布式系统需要关注通信延迟、容错性和一致性。

  • RPC 通信

    • 使用 gRPC 实现高效的跨节点通信。
    • 示例:定义一个简单的 RPC 服务:
      service Greeter {
          rpc SayHello (HelloRequest) returns (HelloReply);
      }
      
  • 分布式存储

    • 利用 Raft 或 Paxos 算法实现数据一致性。
    • 示例:使用 Raft 选举算法管理节点:
      enum class Role { Follower, Candidate, Leader };
      Role currentRole = Role::Follower;
      
      void startElection() {
          currentRole = Role::Candidate;
          // 向其他节点发送投票请求
      }
      
  • 一致性与容错性

    • 使用 CAP 理论指导系统设计。
    • 通过心跳机制监测节点健康状态。

9.5 操作系统设计

C++ 的底层特性使其适合用于操作系统的开发。

  • 内核模块开发

    • 示例:实现简单的任务调度器:
      struct Task {
          int id;
          void (*taskFunc)();
      };
      
      std::vector<Task> taskQueue;
      
      void scheduler() {
          while (true) {
              for (auto& task : taskQueue) {
                  task.taskFunc();
              }
          }
      }
      
  • 内存管理

    • 实现简易的分配器:
      class SimpleAllocator {
          char* buffer;
          size_t size;
          size_t offset;
      
      public:
          SimpleAllocator(size_t size) : size(size), offset(0) {
              buffer = new char[size];
          }
      
          void* allocate(size_t bytes) {
              if (offset + bytes > size) return nullptr;
              void* ptr = buffer + offset;
              offset += bytes;
              return ptr;
          }
      
          ~SimpleAllocator() { delete[] buffer; }
      };
      
  • 文件系统

    • 实现简单的文件读取与写入功能。

9.6 性能监测与调试

高效的性能监测和调试工具是系统设计成功的关键。

  • 性能监测

    • 使用 Valgrind 或 Perf 分析性能瓶颈。
    • 使用 gprof 生成函数调用图。
  • 日志记录

    • 使用 spdlog 等高效日志库跟踪系统状态。
  • 调试工具

    • 使用 GDB 调试运行时问题。
    • 利用 AddressSanitizer 检测内存泄漏。

9.7 案例研究:分布式消息队列

以下是一个简单的分布式消息队列设计方案:

  • 架构

    • 生产者-消费者模型:多个生产者将消息写入队列,消费者从队列读取消息。
    • 分布式存储:通过分片存储大规模数据。
  • 实现

    • 消息队列的数据结构:
      struct Message {
          int id;
          std::string content;
      };
      
      class MessageQueue {
          std::queue<Message> queue;
          std::mutex mtx;
      
      public:
          void push(const Message& msg) {
              std::lock_guard<std::mutex> lock(mtx);
              queue.push(msg);
          }
      
          Message pop() {
              std::lock_guard<std::mutex> lock(mtx);
              if (queue.empty()) return {};
              Message msg = queue.front();
              queue.pop();
              return msg;
          }
      };
      
  • 优化

    • 使用内存池存储消息体。
    • 添加分区逻辑以支持分布式存储。

总结

本章从嵌入式开发到分布式系统,全面探讨了 C++ 在系统设计中的实际应用。通过模块化设计、性能优化和工具链支持,读者可以构建高效、稳定且可扩展的系统。本章不仅提供了具体的实现案例,还分享了设计的核心思想,为读者的 C++ 系统开发实践奠定了坚实基础。

verilog学习|《Verilog数字系统设计教程》夏宇闻 第三版思考题答案(第九章) Verilog数字系统设计教程(第三版)夏宇闻等编著 【第九章】 阅读详情

相关推荐

【笔记】 通信原理 第九章 数字信号的最佳接收

复习通信原理过程中所记笔记

weixin_45931079的博客 5324

c++设计模式demo

⾼层模块不应该依赖低层模块,⼆者都应该依赖抽象;抽象不应该依赖具体实现,具体实现应该依赖于抽象;⾃动驾驶系统公司是⾼层,汽⻋⽣产⼚商为低层,它们不应该互相依赖,⼀⽅变动另⼀⽅也会跟着变动;⽽应该 抽象 ⼀个⾃动驾驶⾏业标准,⾼层和低层都依赖它;这样以来就解耦了两⽅的变动;⾃动驾驶系统、汽⻋⽣产⼚商都是具体实现,它们应该都依赖⾃动驾驶⾏业标准(抽象);⼀个类应该对扩展开放,对修改关闭;不将变量类型声明为某个特定的具体类,⽽是声明为某个接⼝。

jianfeng123123的博客 1171

《低功耗方法学》翻译——第九章:频率、电压缩放设计

第九章:频率、电压缩放设计

记录所学,分享知识,结识挚友 1213

C++之设计原则

低耦合就是降低彼此的依赖,高内聚就是职责尽量单一。如有问题,欢迎交流指正!

a20040518的博客 744

MetaGPT | 第十章:架构师:系统设计、API 与调用流程

Architect字段值nameBobprofileArchitectgoal设计简洁、可用、完整的软件系统架构足够简单,使用合适开源库,并与用户需求使用同一语言toolsEditorRoleZeroactionswatchWritePRD这说明架构师主要关注产品经理输出的 PRD 消息。当WritePRD完成后,消息的cause_by会匹配架构师的_watch,从而触发系统设计。字段含义实现方案和技术选型File list项目文件列表,只需要相对路径数据结构、类、方法、接口和关系。

weixin_43674738的博客 17

系统架构设计-如何设计架构

系统架构设计-如何设计架构 阐述了架构设计的思想和理念

C++课程设计:学生管理系统设计

高级程序设计课程设计 一、教学目标和基本要求 本课程全面系统的学习面向对象程序设计的基本概念,基本语法和编程方法。正确理解掌握C++面向对象程序设计的基本特性:类,对象,继承与派生,多态,虚函数,模板,流类库等。遵循软件过程的各个环节进行系统分析、设计、实现、集成、测试,了解当前常用的软件开发工具(Visual 2017),培养学生解决实际问题的能力。 二、考核方式及办法: 完成包括从概要设计、详细设计、代码编写、程序调试、运行在内的一系列程序设计及文档撰写,要求系统调试成功、可正...

Name Yan 2万+

傻白入门芯片设计,SystemVerilog Assertion(SVA)学习(二十一)

对SVA(SystemVerilogt Assertion)有了更深刻的认识,对经典的AveMC形式验证工具进行了介绍

qq_46675545的博客 8473

一本书的故事《搜索架构之道:App中的搜索系统设计与优化实践》-微信读书中的热门划线(第九章)

《搜索架构之道》分享第九章网络层优化内容,重点探讨了App中网络模块统一管理的重要性。书中指出,通过桥接层隔离系统API、接口层统一封装网络能力,可实现网络通信的复用和资源共享,确保各业务模块调用的一致性和可维护性。作者整理了微信读书中的热门划线并附注解,强调统一网络层能降低维护成本、隔离系统变动影响,同时支持原生与网页功能的资源互通。该书已在京东、当当等平台上架。

俩毛豆的博客 1152

VMware Workstation Pro 16 安装 Ubuntu 20.04

VMware Workstation Pro 16 安装 ubuntu 20.04目录环境VMware Workstation下载Ubuntu 20.04下载安装过程 目录 环境 Windows 10 Workstation 16 Pro for Windows Ubuntu 20.04 LTS 64位 desktop版本 VMware Workstation下载 链接: https://www.vmware.com/products/workstation-pro/workstation-pro-eval

qq_45642410的博客 1万+

AppFlow实战:零代码将Dify接入企业微信的完整指南

本文提供了一份零代码将Dify AI应用接入企业微信的完整实战指南。通过使用阿里云AppFlow作为无代码连接器,详细讲解了从获取Dify API密钥、创建企业微信应用到配置自动化流程的全过程,帮助团队快速将AI能力无缝融入日常协作,大幅提升工作效率。

php55的博客 808

信息系统分析与设计 第九章 系统设计概述

文章目录系统设计的任务要求系统设计的内容系统设计说明书 系统设计的任务要求 通俗地说,设计就是要回答“怎么做” 完成技术实现方案的制定,即信息系统的物理模型 -一个逻辑模型,可以提出多个物理模型 -根据物理模型进行实施,得到最终的物理系统 系统设计的目标 -设计系统之前,先看看评价信息系统的标准,这些标准对任何设计方法都适用: 信息系统的功能:是否满足用户的需求 系统的效率:响应时间、操作的方便性 系统的可靠性:抗干扰能力、故障恢复 系统的工作质量:准确性、使用效果 系统的可变更性:修改和维护的难易程度 系

Lora青蛙的博客 1199

拉普拉斯矩阵

1、预备知识 拉普拉斯矩阵定义为:L=D-W。其中,D为度矩阵,W为权重矩阵。 (1)D是对角矩阵,对角线上的元素时节点的度,即所有与该节点相关联的边的权重之和;对角线以外的元素为0。有向图的对角矩阵分为 出度矩阵 和 入度矩阵。 图1.1 无向图中的度矩阵 (2)W在无向图中是对称矩阵,在有向图中是非对称矩阵。 ...

zzhe 1万+

信息系统分析与设计——第九章系统设计

信息系统分析与设计 期末 第九章 系统设计

m0_52351604的博客 983

DC Error: The power pin VDD on the cell UASA1/CG_X8_Rdsd2pcm is unconnected. (UPF-581)

【代码】DC Error: The power pin VDD on the cell UASA1/CG_X8_Rdsd2pcm is unconnected. (UPF-581)

baidu_34971492的博客 970

YOLOv13改进策略【Backbone/轻量化】| 替换骨干网络 CVPR-2024 StarNet,超级精简高效的轻量化模块

本文记录的是。StarNet设计简洁,没有复杂的设计和精细调整的超参数,仅是一个 4 阶段的分层架构。并且其中能够在低维空间计算的同时考虑极高维的特征这一特性,进而提高模型精度。本文在替换骨干网络中配置了原论文中的starnet_s1starnet_s2starnet_s3和starnet_s4七种模型,以满足不同的需求。

Limiiiing的博客 671

重读《人月神话》:第九章“削足适履”

在资源受限的年代,空间即成本,程序员必须如诺亚般精巧布局。布鲁克斯以OS/360为例,揭示规模膨胀的根源:局部优化取代全局视野,缺乏整体预算与沟通导致系统失控。他提出“空间-时间折衷”与数据重构的战略思维,强调数据表达决定程序本质。今日虽内存充裕,但微服务、依赖膨胀等“隐形规模”仍威胁系统健康。真正的编程智慧,在于超越代码,从数据与架构层面实现战略突破。

MLM888的博客 185

华为OD机试 - 统计文本数量(Java 2025 A卷 100分)

华为OD机试 2025A卷题库疯狂收录中,刷题。

学Java,找哪吒 1438

《信息安全系统设计》第九周

让AI(kimi,元宝等)阅读学习内容并进行总结,教材内容可以使用微信读书或者云班课电子教材第九章主要介绍了进程和系统调用的概念,以及如何在C程序中使用这些概念来创建和控制进程。系统调用(System Calls)系统调用是C程序与操作系统内核交互的接口,用于执行如文件操作、进程控制等任务。system()函数是一个常用的系统调用,它允许程序执行一个命令字符串,就像在命令行中输入一样。进程控制进程是程序运行的实例,每个进程都有一个唯一的进程标识符(PID)。fork()

wzy20031004的博客 1226

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

STM32F407中文手册

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

FPGA电子系统设计项目实战 VHDL语言 第2版 王振红

FPGA电子系统设计项目实战 VHDL语言 第2版 王振红 【下载地址】FPGA电子系统设计项目实战VHDL语言第2版王振红 这是一本专注于FPGA电子系统设计的实战指南,适合初学者和进阶开发者。全书共11章,从FPGA设计基础到VHDL语言应用,再到综合电子系统设计实例,内容全面且实用。通过深入浅出的讲解,读者不仅能掌...

gitblog_06764的博客 1282

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

第九章:未来已来——程序员的长期生存哲学

程序员转型教程

Xin_ye10086的博客 311

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

【通信原理-第九章】

通信原理第九章-数字信号的最佳接收的基本概念。

qq_45562377的博客 2415

Linux系统第九章作业,第九章习题答案

第九章练习题答案1. 区分 rpm -qi -qf -ql -qa四个不同选项组合的作用rpm -qi //查询已经安装的某个rpm软件包的信息rpm -qf //查询某个程序文件是由哪个rpm软件包安装的rpm -ql //查询某个rpm软件包的所有安装文件rpm -qa //查询所有已经安装的rpm软件包2. rpm -qi 后面如果跟一个未安装的包名,会显示什么信息会提示该软件包没有安装3....

weixin_29173299的博客 481

架构之美第九章-架构与设计

架构是系统设计的一部分,它突出了某些细节,并通过抽象省略掉另一些细节。所以,架构是设计的一个子集。关注实现系统组件的开发者可能不会特别关心所有组件如何装 配在一起,而是主要关注少数组件的设计和开发,包括他们必须遵守的架构约束和可以应用的规则。因此,开发者和架构师面对的是系统设计的不同方面。         如果说架构关注的是组件之间的关系和系统组件外部可见的属性,那么设计还要关注这些组件的内部

星火燎猿 1423
上一篇: 第八章:C++ 实践
下一篇: 第十章:C++ 标准
weisonx
博客等级 码龄9年 155粉丝 86原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

weisonx

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值