I&C SCI 46 Finding Balance in Nature

SpringBoot+Vue+MySQL 高校学科竞赛平台 完整可运行版(源码+文档) 本项目基于SpringBoot+Vue+MySQL构建高校学科竞赛管理平台,覆盖学生、教师、领队教师、管理员四大角色,实现竞赛发布、报名、刷题、评分、公示等全流程闭环管理。系统架构清晰,技术主流,配套完整源码、数据库脚本、万字论文、开题报告、答辩PPT及部署文档,支持一键运行,适用于毕业设计、课程设计及院系二次开发,真正实现“开箱即用”。 阅读详情

I&C SCI 46 Fall 2024 Project 4: Finding Balance in Nature

Due at 9:30 AM. You may use late submissions as usual.

Reviewing related material

I encourage you to review your lecture notes for the Binary Search Tree portions of this class,

especially the portions about balancing trees. The data structure we covered this quarter for a

balanced tree is called a Crumple Tree. Supplemental reading is posted on Canvas.

Very important note: it is not enough to implement some type of binary search tree for this

assignment. For the vast majority of the points, your type must be a Crumple Tree. Attempting

to fool the auto-grader is a decidedly bad idea.

Requirements

In this project you will be implementing the Level-balanced tree data structure as a class named

CrumpleTree. The class consists of the following functions which you are responsible for

implementing and have been started for you in CrumpleTree.hpp:

CrumpleTree()

This is the constructor for the class. You should initialize any variables you add to the

class here.

~CrumpleTree()

This is the class destructor. You are responsible for freeing any allocated memory here.

You will most likely be allocating memory to store the nodes within the tree. Since these

allocations need to be dynamic, as we don’t know how large the tree will be, they should

be freed here in the destructor. It’s your job to come up with a traversal algorithm to

accomplish this. Note, if you elect to use shared pointers or unique pointers the compiler

will generate code to deallocate the memory for you if certain conditions are met. You

should only use these features of the standard library if you already understand them or

are willing to put in extra effort. In most industry settings features like these will be used

as opposed to explicitly implemented destructors.

However, be advised that course staff are not expected to know these and might not be

able to help you debug problems with them. If you are unfamiliar with shared or unique

pointers, use traditional (raw) pointers if you are expecting help with debugging.

[[nodiscard]] size_t size() const noexcept

This function returns the number of keys stored in the tree. It returns the count as a

size_t. It is marked const (also known as a constant member function) because it

should not modify any member variables that you’ve added to the class or call any

function functions that are not marked const as well. The advantage of marking this

function as const is that it can be called on constant CrumpleTree instances. It also

allows the compiler to make additional optimizations since it can assume the object this

function is called on is not changed. This is a fairly good StackOverflow answer that

goes into additional detail.

[[nodiscard]] bool empty() const noexcept

This function simply returns whether or not the tree is empty, or in other words, if the tree

contains zero keys. Marked const because it should not change any member data.

Marked noexcept because it should not throw any exceptions.

bool contains(const K & key) const noexcept

Simply checks to see if the key k is stored in the tree. True if so, false if not. Once

again, this function does not modify any member data, so the function is marked const.

Since this is a balanced tree, this function should run in O(log N) time where N is the

number of keys in the tree. This is accomplished through the on-demand balancing

property of Crumple Trees and a consequence of the height of the tree never exceeding

O(log N). IMPORTANT: when comparing keys, you can only assume that the < and ==

operator has been defined. This means you should not use any other comparison

operators for comparing keys.

std::optional<unsigned> Level(const K & key) const

This returns the level on which the given key is stored in the tree. If the tree does not

contain this key, return std::nullopt.

IMPORTANT: when comparing keys, you can only assume that the < and == operator

has been defined. This means you should not use any other comparison operators for

comparing keys.

Value & find(const K & key)

Like contains(), this function searches for key k in the tree. However, this function

returns a reference to the value stored at this particular key. Since this function is not

marked const, and it does not return a const reference, this value is modifiable through

this interface. This function should also run in O(log N) time since it is bound by the

height of the tree. If the key k is not in the tree, a std::runtime_error should be

thrown.

const Value & find(const K & key) const

Same as the constant version of find, but returns a constant reference to the stored

value, which prevents modification. This function is marked const to present the find

(or “lookup”) interface to instances of CrumpleTree which are marked const

themselves. This means that member data should not be modified in this function. For

example, the following code would call the version of find() marked constant:

CrumpleTree<int, int> tree;

const CrumpleTree<int, int> & treeRef= tree;

treeRef.find(1);

Warning: this function will not be compiled until you explicitly call it on a constant

CrumpleTree as in the example above. If you submit code to GradeScope, and that

system says it does not compile, make sure you've done this. You will end up with a

zero on the assignment if your code does not compile when I pair it with test cases that

call every function. Testing comprehensively is your responsibility!

void insert(const K & key, const V & value)

Adds a (key, value) pair to the tree. If the key already exists in the tree, you may do as

you please (no test cases in the grading script will deal with this situation). The key k

should be used to identify the location where the pair should be stored, as in a normal

binary search tree insertion. Since this is an level-balanced tree, the tree should be

rebalanced if this insertion results in an unbalanced tree.

Note: this is by far the most difficult part of this project.

void remove(const K & key)

Removes the given key from the tree, fixing the balance if needed. If the parameter does

not exist in the tree, do not modify the tree.

I recommend you work on both insert and remove in parts; do not attempt to do the

entire insert, or entire remove, in one session. Test that you are able to get some cases

to pass before moving onto other types of cases.

[[nodiscard]] std::vector<K> inOrder() const

Returns a vector consisting of the keys in the order they would be explored during an

in-order traversal as mentioned in class. Since the traversal is “in-order”, the keys should

be in ascending order.

IMPORTANT: this function, as well as preOrder() and postOrder(), are easy to forget to

test separately. Be very careful with these three, as their value (in terms of test cases

that rely on them) is disproportionately high. Please be absolutely sure you got these

right.

[[nodiscard]] std::vector<K> preOrder() const

Returns a pre-ordering of the tree. For the purpose of this assignment, the left subtree

should be explored before the right subtree.

[[nodiscard]] std::vector<K> postOrder() const

Returns a post-ordering of the tree. For the purpose of this assignment, the left subtree

should be explored before the right subtree.

Additional Notes

● Your implementation must be templated as provided.

○ Be sure yours works for non-numeric types! char is a numeric type.

○ Review the warnings in the lab manual, the grading policies, and in particular the

warning about templated code in the “Grading Environment” section.

● You do not need to write a copy constructor or an assignment operator on this project,

but knowing how to do so is generally a good thing.

● As stated in the contains() function: for comparing keys, use the “natural” comparison

offered by <. You should assume that < and == are defined for any object used for Key.

Any test cases provided will have something for the key that has this defined.

● The project will not build by default because a reference to a local variable is returned in

the find() functions. You will need to write an implementation that doesn’t do this.

Restrictions

Your implementation must be implemented via linked nodes in the tree format from the lecture.

That is, you may not have a “vector-based tree.” This means you will probably need to create a

new structure inside of your CrumpleTree class which will represent the nodes.

You may use smart pointers if you would like to do so. However, course staff are not required to

help you with smart pointers, including debugging code that uses them. I advise students who

are not already familiar with smart pointers to not use them for this project; they're good to

learn, but this is not the project on which to learn them.

You may not use any containers in the C++ standard template library in this assignment except

for std::vector. Furthermore, std::vector may only be used when implementing the

three traversals (in-order, pre-order, post-order). For what it’s worth, you won’t miss it for this

assignment. As always, if there’s an exception that you think is within the spirit of this

assignment, please let me know.

Your implementation does not have to be the most efficient thing ever, but it cannot be “too

slow.” In general, any test case that takes 30 seconds on GradeScope may be deemed a

wrong answer, even if it will later return a correct one. The memory check cases have a

significantly higher timeout period, and are cases which your code will very likely complete (if we

aren't running memcheck on the same code) in milliseconds.

For any assignment in this class, including this one, you may not use the directive using

namespace std; anywhere in your code. Doing so will earn you a zero for the project.

If you are found to be attempting to fool the auto-grader, perhaps by implementing a

different type of balanced binary search tree, this will be treated as a serious case of

academic dishonesty -- it will result in a report to AISC and an F in the class.

In the past, a small subset of students have attempted to contact the inventors of Crumple Trees

to get help on this project. This does not qualify as seeking reasonable help, and there are

plenty of UCI course resources available to you.

Additional Grading Note

This is an additional warning that the public tests are not comprehensive. Remember that the

compiler does not compile functions which are not used. Thus, at the bare minimum you should

add additional unit tests which get all of your code to compile. This has been a problem in the

past; do not ignore that warning. Using different template types will help to make sure you

don’t accidentally bake in assumptions about the type of the Key or Value. Always commit your

unit tests with your code.

The points available for this project are broken down into three categories:

● Basic BST functionality. To have your code tested to earn these points, you must pass

all test cases marked [RequiredBasicFunctionality]. Nothing in this portion requires that

you have a balanced tree, although it is possible that a poor implementation of balancing

could "break" this; please be careful. This portion is worth 1 point

● Crumple Tree functionality. To have your code tested to earn these points, you must

pass all test cases marked [RequiredCrumpleTree]. This portion is worth YY points.

Note that you do not need full CrumpleTree functionality to pass the required cases,

which would allow you to be evaluated on the remaining ones. This is one reason we

recommend you work with cases. This portion is worth 4 points.

○ There may be test cases within this that require only insertion procedure to work

correctly. However, the required case prerequisite requires you to get at least one

delete case to work properly. This is on purpose.

● Memory check. Some of these cases will require some simple functionality to be

reasonably efficient; this is due to a constraint with how long GradeScope will run a

submission. We test with small cases that would run quickly if we were not checking for

memory, and we give a good maximum amount of time for each to run (7-10 minutes

each). This portion is worth 1 point.

Frequently Asked Questions (FAQs)

Q1. Does _____ make problem-solving in this project trivial or is it allowed?

The following parts are permitted for use in this project: std::pair, std::max, std::abs,

std::swap. If you have another part of the standard library in mind, please ask on edStem.

Q2. Are we allowed to include the <functional> library so I can make a lambda function recursive?

Sure, if you think it will help you.

Q3. Can I include parts of the standard library to test my trees?

You can use any library for debugging purposes. The only disallowed functions are for the

final, active submission, submitted to GradeScope.

Q4. Can you use the vectors you got from the in-order, pre-order, or post-order functions in other

functions?

No. You also don't need to. However, you may use std::vector within helper functions of

in/pre/post order traversals.

Q5. Are we allowed to use stacks/queues for the inorder/postorder/preorder functions?

No. You are not allowed to use any standard containers except for in your traversal

implementations where you are allowed only std::vector.

Q6. Are we allowed to use vectors or arrays to store shapes?

No, but I'm sure you could do the same without using an array or vector.

Q7. Are > (greater than) and <= (equal to or greater than) off-limits when comparing keys?

Yes, any other operators other than < (less than) and == (equal to) are off-limits when

comparing keys.

Q8. Can I use recursion to destruct the trees?

You can use recursion for a destructor. However, you should also consider the off chance that

the stack size is exceeded and the destruction fails resulting in unfreed memory.

Q9. What to do if the passed in key does not exist in the remove() function?

You can handle this case as desired; we will not be testing it.

Q10. If the deleted node is not a leaf and has two children, should we replace it with successor or

predecessor?

Both are correct to do, and the grading script will accept either.

Q11. Do we need to have O(log n) time complexity for insert and remove?

That is the target time for balanced binary search trees, including Crumple trees.

Q12. Are we allowed to implement other level-balancing binary search trees on project 4?

No.

Q13. Are we expected to handle very large trees?

Yes, you can assume that the size of the tree will not exceed the maximum uint64_t value.

Q14. Am I permitted to add my new function to the class?

Yes. Also, it doesn’t matter where you make the helper functions as long as you don't change

the public functions and their parameters.

VS Code + EIDE + Clangd 构建 Keil/MDK 嵌入式开发新范式 嵌入式C/C++开发长期受限于传统IDE的语法理解弱、导航卡顿、跨工程复用难等问题。Clangd作为基于AST的现代语言服务器,结合EIDE对Keil uVision和ARM MDK工程文件(.uvprojx)的深度解析能力,可将编译配置、芯片型号、内存模型、扩展关键字等语义精准翻译为标准compile_commands.json,从而实现智能跳转、宏展开识别、结构体实时展开等高阶编辑体验。该方案不替换Keil/MDK编译与烧录流程,仅升级代码理解层,天然兼容STC8051、STM32 Cortex-M、G 阅读详情

相关推荐

ESP32+LED12864液晶屏实战:手把手教你显示中文与自定义图标(附完整代码)

本文详细介绍了如何使用ESP32单片机驱动带字库的LED12864液晶屏,实现中文显示与自定义图标。从硬件选型、接线方案到驱动编写、字库解析,提供了完整的实战代码与优化技巧,并最终构建了一个智能家居控制面板的完整示例项目。

weixin_29212867的博客 148

InnoDB 内存结构总览:Change Buffer、AHI 与 Log Buffer

本文系统梳理InnoDB内存结构中的ChangeBuffer、Adaptive Hash Index(AHI)与LogBuffer。ChangeBuffer缓存二级索引页不在内存时的变更,减少随机IO,仅在页加载时合并;聚簇索引修改立即执行,因数据本身不可延后。AHI基于高频等值查询自动构建哈希索引,加速定位,仅支持等值操作。LogBuffer为redo log内存缓冲,配合磁盘日志实现崩溃恢复。三者均服务于性能优化,其中ChangeBuffer与AHI共享BufferPool空间,而LogBuffer独立

bksczm的博客 309

ubuntu18.04 升级Ubuntu 20.04

Ubuntu 18.04升级20.04指南:首先备份重要数据,更新当前系统并检查新版本可用性(sudo do-release-upgrade -c)。确认升级后执行sudo do-release-upgrade,按提示完成操作。升级过程需耐心等待,完成后重启系统。注意:升级前务必备份数据,确保系统为最新版本,以降低风险。升级后即可使用Ubuntu 20.04系统。

https://ophome.blog.youkuaiyun.com,在IT行业有多年的工作经验,尤其是在Python、Linux、负载均衡、Nginx和服务器运维等领域。 1061

信创环境下PageOffice文档控件适配与实践

信创适配做到文档控件这一层,拼的已经不是"有没有国产版本",而是同一个功能在两类终端上是否真的等价。等价的标准很具体:同一次点击能得到同样的结果,同一份公文能得到同样的版式,同一个项目不需要维护两套代码。这背后是三件并不轻松的工作:服务端用一套接口同时支撑两类终端,客户端把两种系统与四种芯片的安装包分发清楚,文档内核层由产品侧跟着 WPS 的版本走。浏览器这一层的压力,则被收进了产品自己的窗口里——升级节奏由产品掌握,不再交给运气。

zi_wu_xian的专栏 336

手把手教你用FPGA解析AD9680的JESD204B数据流(附Verilog代码)

本文详细介绍了如何利用FPGA解析AD9680的JESD204B数据流,包括协议核心机制、硬件平台搭建、Verilog代码实现及调试技巧。通过实战案例和代码示例,帮助工程师快速掌握高速ADC数据采集与处理技术,提升系统性能。

weixin_33640562的博客 374

银河麒麟V10 SP3离线安装Nginx1.21.5全记录(附11个rpm包下载清单)

本文详细记录了在银河麒麟V10 SP3操作系统上离线安装Nginx 1.21.5的全过程,包括11个必备rpm包的下载清单。通过分步骤的实战指南,帮助用户在国产化环境中高效部署Nginx服务,涵盖安装、配置、调优及故障排查等关键环节,特别适合金融、政务等对安全性要求高的场景。

weixin_30872337的博客 609

第三篇 第 6 课

前置:第三篇第 1 课(stdx 引入),第二篇第 1 课(std.regex)。环境:仓颉 SDK 1.2.0。本文所有代码与输出均逐行实测。

weixin_41618057的博客 557

Qt QCustomPlot 图形库详解及使用

QCustomPlot 是一个开源的 Qt C++ 库,专门用于创建数据图表。易于集成到 Qt 项目中。支持多种图表类型,如折线图、散点图、条形图等。提供丰富的交互功能,如缩放、平移、选择和拖动。高度可定制,支持图形的各种样式设置。// 添加第一条曲线i < 101;++i) {// 设置曲线颜色// 添加第二条曲线i < 101;++i) {// 设置曲线颜色// 设置散点样式// 添加图例。

MusicScore的博客 766

【从零理解 Spring AI · 12】MCP 的两种角色:做客户端还是做服务端

上一篇讲了 MCP 的概念:标准协议、三大角色、M+N 替代 M×N。

nice_lcj520的博客 614

044、镜头脏污与异物检测:产线 AOI 检测方案与 ISP 脏污补偿

文章摘要(148字) 本文针对镜头生产中的脏污检测问题,提出产线AOI检测与ISP补偿结合的解决方案。产线端采用明场、暗场、偏振三通道联合检测技术,将油污漏检率从8.3%降至0.2%。ISP端通过RAW域局部梯度分析和频域补偿算法,动态修复产线漏检的微小脏污。作者结合实战案例,详细分析了传统灰度阈值法的局限性,并给出多模态检测的代码实现要点,强调必须建立"产线拦截+终端补偿"的双重防护机制。

sundong_81的博客 230

iStoreOS路由器(openwrt软路由) AdGuard Home 客户端 IP 总是 localhost(127.0.0.1)?这样设置让你精准识别真实IP!

在iStoreOS等软路由上部署AdGuard Home时,客户端IP常显示为localhost(127.0.0.1)。本文详细介绍如何让adguardhome直接识别客户端真实IP🌐,帮助你实现网络流量的精准追踪和管理。🔍

XiaoqiangClub的博客 2270

pcl2启动器下载(Minecraft PCL2 启动器 最新版 安装与使用说明)

摘要:PCL2(Plain Craft Launcher 2)是一款面向 Minecraft 的第三方启动器,支持正式版与快照版本管理、模组与整合包安装、Java 运行时自动匹配,绿色免安装、双击即可运行。适合在 Windows 上玩单机整合包、需要多版本共存或离线启动的用户使用

2611_96675819的博客 226

Python白色飘雪(完整代码)

Python绘制白色飘雪动画的完整代码。

AIGC 3万+

spring boot 4集成SQLLite,及其SQLLite的建库

spring boot 4集成SQLLite,及其SQLLite的建库

weixin_41463944的博客 231

STM32F407中文手册

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

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Java 集合容器高频面试题全解:HashMap 树化阈值、1.7 死循环与 ConcurrentHashMap 演进(2026 招聘 JD 真题复盘)

HashMap 树化阈值 8 的泊松分布依据、退化阈值 6 的防抖设计、JDK 1.7 头插成环死循环的排查与修复、1.8 尾插后为何仍线程不安全、ConcurrentHashMap 放弃分段锁的原因与 ForwardingNode 协作扩容、computeIfAbsent 死锁陷阱、大集合找重复的场景题选型,附三层追问链自测。题目来源为 38 期公开招聘 JD 样本与字节、拼多多、建行、美团、快手公开面经。

蒙眼过河 427

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

spdlog 同步日志库使用详解

spdlog是一个轻量级 C++ 日志库,支持同步日志、异步日志、多线程日志、日志文件轮转和自定义日志格式。对于嵌入式 Linux 应用开发,我建议先使用。它可以帮我们完成:日志级别过滤。时间戳和线程 ID 输出。日志格式化。终端和文件输出。多线程安全写入。日志文件按大小或时间轮转。我们不需要自己实现互斥锁、文件写入、日志格式化和轮转等底层功能。

zengjiajun2006的博客 1124

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

JavaSE通关手册:数据类型与变量

代码无需额外处理,编译时编译器自动完成转换。

xys_678的博客 236

IDEA 简介:从零认识 IntelliJ IDEA

IDEA 全称,是由 JetBrains 公司开发的一款主流 Java 集成开发环境(IDE)。它集代码编辑、编译、调试、测试、版本控制、构建管理等功能于一体,被大量 Java 开发者视为日常开发的首选工具。所谓 IDE(Integrated Development Environment,集成开发环境),就是把写代码所需的各类工具整合到同一个界面中。相比只用文本编辑器加命令行编译,IDE 能显著减少重复操作,让开发者把精力集中在业务逻辑上。

ztI10的博客 184

Docker部署linkding:HTTPS与数据备份

部署私人书签库,除了让页面能够打开,还需要考虑几个实际问题:重建容器后数据是否保留、登录和保存是否正常、升级前怎样备份,以及出现 502 或 CSRF 错误时从哪里检查。本文使用 Docker Compose 部署 linkding,采用默认 SQLite 数据库,通过 Caddy 提供 HTTPS,并完成账户创建、数据持久化验证和备份。如果重建后账户或书签消失,应先检查是否换了项目目录、改了挂载路径,或者启动了另一套实例,不要急着重新初始化。遇到权限问题,应根据日志确认具体目录和运行用户,再调整权限。

tedcloud123的博客 193

C++20协程怎么运行?原理与三大核心组件深度剖析

C++20协程是轻量级的无栈状态机,通过co_await、co_yield、co_return实现挂起与恢复,由Promise、协程句柄和Awaitable三大组件协同工作。协程与线程互补,适用于高效管理大量并发I/O任务,显著降低上下文切换开销。其核心在于编译器生成的状态机机制,需配合库(如cppcoro)使用。掌握Promise控制逻辑、句柄生命周期管理及Awaitable语义,是构建高性能异步程序的基础。

Lucis__的博客 335

动态代理两大流派:JDK 代理与子类代理

业务类想加日志,最直白的写法是侵入式修改: 问题很明显:每个方法都要改一遍,改一个业务要动十处。代理模式的解法是:调用方不直接依赖 ,而是依赖一个代理对象。代理对象长得跟目标一模一样,调用它 → 代理先执行增强逻辑 → 再转调真实对象。 关键在于:代理对象的类型是哪来的?这就是"动态"二字的含义:代理类在运行时才诞生。两个角色: 承载增强逻辑, 负责生成代理类。 组装代理并调用: 输出: 业务代码 一行没动,增强逻辑全在 里。这就是 AOP 的味道。 内部四步: 第 2 步 内部:先查 (同一个接口

Android的专栏 661

c++ explicit关键字详解

explicit。

拒绝AI文,努力在AI时代写出感动人心的好文章 169

Java 项目实战:交友项目后台系统——网关统一鉴权与 B 端管理后台

本次改造通过引入SpringCloud Gateway实现网关统一鉴权与路由,新建mf-admin管理端复用C端域服务(Dubbo调用),实现管理员登录与用户管理四件查询。核心套路:网关白名单+双体系JWT(同工具不同payload)、管理端零直连业务库、分页形态区分(MySQL自动count/Mongo手动count)、浏览器端独立聚合。踩坑12条,附自检清单与后续改造方向,可复用于多角色后台系统。

Wang的专栏 63

Teamcenter Java SOA 开发:连接、查询与保存

本文介绍如何通过 Java 调用 Teamcenter SOA 接口实现外部系统对接,涵盖连接登录、查询保存等核心操作。以最小闭环示例展示 Connection、Service、ModelObject 等关键组件的使用,强调错误处理与事务管理要点。梳理了 DataManagement、Query、File Management 等 API 模块分工,并结合“工作移交WebService”案例,说明幂等性设计与流程状态返回的重要性。适用于 Web 门户、ERP 集成等场景,建议批量操作用 bulk 接口优化性

软件工程师文艺 277

TRingBuffer两端都能增删(快递站版)

TRingBuffer 是一个支持两端增删、下标访问且容量动态增长的环形双端队列。它通过无符号索引的永不归零设计,利用减法自动模运算实现空满判断与元素计数,避免了传统环形缓冲浪费格子的问题。内部以票号(索引)标记首尾,扩容时重排元素为连续存储,保证 O(1) 操作与高缓存效率。虽不线程安全,但其高效性使其成为游戏开发中事件队列、命令缓冲等场景的理想选择。

u013768914的博客 315

Mac上装了最新版本的Android Studio,但是没找到jdk的设置选项也没找到jbr的目录

新版Android Studio(2025.3.1+)因三项变更导致常见问题:一、JDK设置移至“DaemonJVM criteria”,新项目默认自动探测或下载JDK;二、JBR目录改名为带版本号的jbr-21等,需进入.app/Contents/查看,或通过About窗口确认运行时;三、命令行缺adb因platform-tools未加入PATH,需在SDK Manager中勾选并配置~/.zshrc中的ANDROID_HOME及PATH。重装或清理残留可解决缺失问题,切勿手动设JAVA_HOME或安装冲

Programming is a highly artistic endeavor 399
上一篇: ARS Reinforcement Learning
下一篇: MSDS 490: Healthcare Analytics and Decision Making
wx____codinghelp
博客等级 码龄2年 771粉丝 115原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值