Codeforces Round #357 (Div. 2) -- D. Gifts by the List(DFS)

YOLO26算法大门区域检测+训练好的模型+285张数据集+pyqt可视化界面.zip 附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[大门(gates)] 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 64 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.6364** mAP50-95 | 0.4539 Precision | 0.7309 Recall | 0.6111 train/box_loss | 0.6662 train/cls_loss | 0.5916 val/box_loss | 1.3351 val/cls_loss | 1.5479 【训练过程分析】 训练过程可分成三个主要阶段:前期、中期和后期。刚开始时,模型的损失函数确实有了显著下降,box_loss 从0.6662开始,经过几轮的迭代,迅速降至0.5左右。但到了中期,loss 的下降速度明显放缓,甚至有停滞不前的趋势。这一现象在val/box_loss的表现上尤其明显,从1.3351缓慢上升至1.4左右,直到训练到64轮时才略有下降。在这一阶段,mAP50从0.6364仅轻微上升到0.64,提升有限。这期间,模型似乎陷入了平台期,进展缓慢,让人感到有些煎熬。从第30轮到第64轮,我频繁查看曲线图,希望能捕捉到一点改善的迹象,但都未能如愿。这个阶段也让我对模型的潜力产生了怀疑,担心训练过程可能需要更长时间才能看到显著改善。 进入后期阶段,尽管损失函数略有下降,但mAP50的提升并不明显,这让人感到非常... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。 立即下载

参考:http://blog.youkuaiyun.com/aozil_yang/article/details/51866239
大体题意:

一个家庭聚会,每个人都想送出礼物,送礼规则是 一个人 先看名单列表,发现第一个祖先 就会送给他礼物,然后就不送了,如果他没找到礼物 他会伤心的离开聚会!告诉你m个祖先关系,和每个人想给谁送!让你求出名单列表!

注意 自己是自己的祖先。

思路:

想一想规则可以知道: 如果祖先关系是 D - > C -> B -> A 那么如果A想给D送礼物,那么BC也必须给D送礼物 如果B 送给C 那么B第一个找到的祖先是C A也应该送给C这就矛盾了!也就是说只要 A想送的礼物和祖先一样或者送给自己就可以了!

vector<int> ans;  
void init()  
{  
    tot = 0;  
    memset(head,-1,sizeof(head));  
}  
void add_edge(int u,int v)  
{  
    edge[tot].to = v;  
    edge[tot].next = head[u];  
    head[u] = tot++;  
}  
void dfs(int u)  
{  
    for(int i = head[u]; i != -1; i = edge[i].next)  
    {  
        int v = edge[i].to;  
        if(fa[v] != fa[u] && fa[v] != v)  
            flag = 0;  
        dfs(v);  
    }  
    if(fa[u] == u)  
        ans.push_back(u);  
}  
int main()  
{  
    int t,C = 1;  
    //scanf("%d",&t);  
    while(scanf("%d%d",&n,&m) != EOF)  
    {  
        init();  
        memset(dep,0,sizeof(dep));  
        for(int i = 0; i < m; i++)  
        {  
            int u,v;  
            scanf("%d%d",&u,&v);  
            add_edge(u,v);  
            dep[v]++;  
        }  
        for(int i = 1; i <= n; i++)  
            scanf("%d",&fa[i]);  
        flag = 1;  
        ans.clear();  
        for(int i = 1; i <= n; i++)  
            if(!dep[i])  
                dfs(i);  
        if(!flag)  
            printf("-1\n");  
        else  
        {  
            printf("%d\n",ans.size());  
            for(int i = 0; i < ans.size(); i++)  
                printf("%d\n",ans[i]);  
        }  
    }  
    return 0;  
}  

然后最强的就是看到师兄用的树链剖分做的。。。ORZ

#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;


#define N 100020
#define M 220000
#define ls (i << 1)
#define rs (ls | 1)
#define md (ll + rr >> 1)
#define lson ll, md, ls
#define rson md + 1, rr, rs

int n, m;
int fst[N], nxt[M], vv[M], e;

int dep[N], fa[N];
int tp[N], son[N], sz[N], tid[N], ed[N], lab[N], dc;

int k;

vector<int> g[N];

bool vis[N];
int id[N];
int a[N];

int cnt[N << 2];

void init() {
    memset(fst, -1, sizeof fst);
    e = 0;
}
void add(int u, int v) {
    vv[e] = v, nxt[e] = fst[u], fst[u] = e++;
}
void dfs(int u, int p, int d) {
    vis[u] = 1;
    sz[u] = 1;
    dep[u] = d;
    int mx = 0;
    for(int i = fst[u]; ~i; i = nxt[i]) {
        int v = vv[i];
        dfs(v, u, d + 1);
        sz[u] += sz[v];
        if(sz[v] > mx) mx = sz[u], son[u] = v;
    }
}

void dfs2(int u, int anc) {
    tid[u] = ++dc;
    lab[dc] = u;
    tp[u] = anc;
    if(son[u]) dfs2(son[u], anc);
    for(int i = fst[u]; ~i; i = nxt[i]) {
        int v = vv[i];
        if(v != son[u]) dfs2(v, v);
    }
    ed[u] = dc;
}

bool cmp(int i, int j) {
    return tid[i] > tid[j];
}
void update(int x, int ll, int rr, int i) {
    cnt[i]++;
    if(ll == rr) return;
    if(x <= md) update(x, lson);
    else update(x, rson);
}

int query(int l, int r, int ll, int rr, int i) {
    if(ll == l && rr == r) return cnt[i];
    if(r <= md) return query(l, r, lson);
    if(l > md) return query(l, r, rson);
    return query(l, md, lson) + query(md + 1, r, rson);
}

int query(int u, int v) {
    int ret = 0;
    while(tp[u] != tp[v]) {
        if(dep[tp[u]] > dep[tp[v]]) swap(u, v);
        ret += query(tid[tp[v]], tid[v], 1, n, 1);
        v = fa[tp[v]];
    }
    if(dep[u] > dep[v]) swap(u, v);
    ret += query(tid[u], tid[v], 1, n, 1);
    return ret;
}



int main() {
    scanf("%d%d", &n, &m);
    init();
    for(int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        fa[v] = u;
        add(u, v);
    }
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        g[a[i]].push_back(i);
    }

    for(int i = 1; i <= n; ++i) {
        if(fa[i] == 0) {
            dfs(i, 0, 0);
        }
    }
    for(int i = 1; i <= n; ++i) {
        if(fa[i] == 0) {
            dfs2(i, i);
        }
    }
    memset(vis, 0, sizeof vis);
    for(int i = 1; i <= n; ++i) vis[a[i]] = 1;
    for(int i = 1; i <= n; ++i) if(vis[i]) id[++k] = i;

    sort(id + 1, id + k + 1, cmp);

    bool f = 1;
    for(int i = 1; i <= k; ++i) {
        int u = id[i];
        for(int j = 0; j < g[u].size(); ++j) {
            int v = g[u][j];
            if(query(u, v) > 0) {
                f = 0;
                break;
            }
        }
        if(!f) break;
        update(tid[u], 1, n, 1);
    }
    if(!f) puts("-1");
    else {
        printf("%d\n", k);
        for(int i = 1; i <= k; ++i)
            printf("%d\n", id[i]);
    }
    return 0;
}
状态估计【卡尔曼滤波kalman】UKF、EKF、粒子滤波PF学习与研究(Matlab代码实现) 内容概要:本文围绕非线性状态估计中的三种经典滤波算法——无迹卡尔曼滤波(UKF)、扩展卡尔曼滤波(EKF)和粒子滤波(PF)展开系统性学习与研究,重点在于通过Matlab编程实现这些算法的核心流程,并将其应用于实际系统的状态估计问题中。文档不仅详细阐述了各算法的数学原理、适用条件与性能差异,还提供了完整的仿真代码与案例分析,帮助读者深入理解其在非线性、非高斯环境下的表现特性。同时,资源拓展至EKF与神经网络融合训练、多源数据融合等高级应用场景,展现了其在智能控制、无人机导航、电力系统状态估计、目标跟踪等领域的广泛应用价值。; 适合人群:具备一定信号处理、控制理论或状态估计基础的研究生、科研人员及工程技术人员,尤其适用于从事自动化、机器人、导航、电力电子与智能系统等相关方向的研究与开发工作者;; 使用场景及目标:① 掌握UKF、EKF与PF在非线性系统中的建模思路与Matlab实现方法,理解其优缺点与适用边界;② 提升科研仿真能力,能够独立构建状态估计模型并进行算法对比验证;③ 将所学方法应用于如电池SOC估算、无人机姿态估计、传感器融合、故障诊断等实际工程问题中;; 阅读建议:建议结合Matlab动手实践,逐行解读并调试所提供的代码,深入理解算法实现细节;同时可延伸学习文中提及的数据融合、神经网络与滤波器结合等进阶主题,以构建完整的状态估计技术知识体系。 立即下载

相关推荐

Plecs全桥LLC谐振变换器仿真模型

内容概要:本文档系统性地整合了电力电子与控制系统仿真领域的丰富资源,聚焦于基于Plecs和Simulink平台的高频软开关变换器建模与仿真,涵盖全桥LLC、双向CLLC、DAB、PFC、Vienna整流器、Buck-Boost等多种典型拓扑结构。资源内容不仅包括闭环控制(如变频控制、移相混合控制、双闭环、恒压恒流双竞争控制)的仿真模型,还配套提供详细的参数设计报告、Mathcad计算书、PPT说明文档及参考文献,构建了从理论建模到工程实现的完整技术链条。此外,文档拓展至状态估计(如卡尔曼滤波、EKF、UKF、PF)与智能算法(如BP神经网络、模型预测控制)在电力系统中的融合应用,为先进控制策略的研究与复现提供了坚实支撑。; 适合人群:面向具备电力电子、自动控制或电气工程等相关专业背景,熟练掌握MATLAB/Simulink/Plecs等仿真工具,从事高频开关电源、新能源变换系统、储能系统或车载电源研发的研究生、高校科研人员及企业工程技术人员。; 使用场景及目标:① 学习并掌握全桥LLC等谐振变换器的核心工作原理与闭环控制系统设计方法,特别是变频与移相控制策略的实现细节;② 利用提供的仿真模型与Mathcad计算工具,快速完成实际项目中的参数设计、性能验证与优化迭代;③ 结合状态估计算法与神经网络等智能方法,开展电力电子系统状态观测、故障诊断或控制策略创新等前沿科研课题的复现与探索。; 阅读建议:建议严格按照资源目录结构循序渐进地查阅,优先下载并运行核心仿真模型,结合对应的设计报告与计算书深入理解其建模逻辑与参数推导过程,重点关注闭环控制架构、软启动策略及中点电位平衡等关键技术环节,并可进一步将状态估计与智能算法模块融入现有模型,探索其在系统优化中的应用潜力。

Codeforces Round #497 (Div. 2) D - Pave the Parallelepiped

这场就不说啥了,打的很爆炸。。 漏了个return false结果函数返回值有问题,下次一定要注意。 D 题又是一个无敌容斥原理。。看来这个东西得好好补补了。 下面的题解算是对CF的editorial的理解和大致翻译吧 问你有一个(A,B,C)的平行六面体,让后让你找出(a,b,c),能够用(a,b,c)把它填满。 问这样的(a,b,c)有几种。 首先肯定要找能整除A,B,C的,也就是找...

GeN的博客 323

伺服电机入门01

编码器输出 旋转信号 , 接收端: 使用ADC 捕捉旋转信号 ,转成数字信号,驱动器得到数字处理, 因为信号量是模拟信号, mcu mpu 等芯片通常内部处理是数字,通过adc 得到数字cpu 才能识别 传输过来的pos 等信息。IPM 芯片示例, IRAM256A 这个芯片已经停产,有换新的,,下面示例来自stmbl 高功率方案,4 步进电机 有全步控制,半步控制 ,微步控制,FOC控制,步进电机也是可以做伺服系统的。以下面几种信号是可以细分,也就是通过细分增加编码器的分辨率,

qq_25160559的博客 969

Codeforces Round #497 (Div. 2) D. Pave the Parallelepiped

难想的DP

ACoder 490

快速修改Petalinux编译生成的rootfs.cpio.gz文件:无需重新编译的实用技巧

本文详细介绍了如何在不重新编译的情况下快速修改Petalinux生成的rootfs.cpio.gz文件,适用于Zynq平台开发。通过解包image.ub、修改rootfs内容并重新打包的完整流程,可显著提升调试效率,特别适合频繁修改配置文件的场景。文章还提供了自动化脚本和进阶应用技巧,帮助开发者优化工作流程。

weixin_28285943的博客 239

Halcon相机标定实战:从参数设置到精度优化全解析

本文详细解析Halcon相机标定的全流程,从基础概念到实战技巧,涵盖参数设置、精度优化及常见问题解决方案。通过实际案例和代码示例,帮助读者掌握工业视觉项目中相机标定的关键技术,提升测量精度和系统稳定性。

weixin_29279153的博客 321

Codeforces Round #497 (Div. 2) A. Romaji

A. Romajitime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVitya has just started learning Berlanese language. It is known that Berlanese uses the L...

Zeolim的博客 335

TSmaster CANFD配置避坑指南:为什么你的PCAN盒不支持最新版本?

本文针对TSmaster配置PCAN硬件进行CANFD通信时的常见问题,提供了详细的避坑指南。重点解析了CANFD配置中TSEG1等关键参数的理解误区,并深入探讨了TSmaster新版本与PCAN硬件驱动之间的兼容性变化,帮助工程师快速定位并解决连接失败或无法发送CANFD报文等问题。

alpha的博客 542

Codeforces Round#497(Div.2)

Codeforces Round#497(Div.2)A罗马字(Romaji )​ 这道题比较水吧,直接暴力判断即可。其中“n”在里面一重循环特殊判断就行了。代码附上#include&lt;cstdio&gt; #include&lt;iostream&gt; #include&lt;string&gt; #include&lt;cstring&gt; using namespace std; i...

ykhrg的博客 459

调试备忘录-SWD协议解析

目录--点击可快速直达 文章目录写在前面1  SWD协议简介2  SWD物理层协议解析2.1  SWD通信时序分析2.2  SWD 寄存器简介2.2.1  DP寄存器2.2.2  AP寄存器2.3  SWD通信流程2.3.1  SWD复位2.3.2  SWD读IDCODE2.3.3  SWD清除错误标志位,并且使能AP调试2.3.4  SWD读取AP IDR(也就是AP寄存器的ID CODE)2.3.5  SWD读写MCU任意寄存器 写在前面 最近由于公司需要,所以就做了个基于SWD协议的离线烧写器。由于.

洛神殇的博客 1万+

shopro 商城,2025年新申请的微信支付提示失败,支付提示 Get Wechat Public Cert Error 问题的修复办法

shopro 商城,最近新申请的微信支付商户 支付提示 Get Wechat Public Cert Error 问题的修复办法

行走的卡路里 1245

codeforces 1008 D. Pave the Parallelepiped(思维+数学)

题目链接:http://codeforces.com/contest/1008/problem/D思路:要铺满明显只要a,b,c分别是A,B,C的因数就好了,但a,b,c可能有重复的排列出现要去掉。。我自己是画了张图列举出了所以情况。。应该有简单的办法吧,但是想不到emmm。#include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;...

llmxby 520

实战指南 | Adjust 与 Facebook、Google Ads 自归因配置全流程解析

本文详细解析了Adjust与Facebook、Google Ads自归因配置的全流程,帮助移动应用出海推广者解决广告归因难题。通过自归因功能(SAN),开发者可以获取更准确的数据、简化配置流程并扩大安装来源覆盖,显著提升广告效果监测和ROI计算效率。

weixin_42528780的博客 537

Codeforces Round #357 (Div. 2) D. Gifts by the List DFS

&#13; D. Gifts by the List&#13; 链接:&#13; http://codeforces.com/contest/681/problem/D&#13; 代码:&#13; &#13; 1 #include&lt;iostream&gt;&#13; 2 #include&lt;vector&gt;&#13; 3 using namespace s...

花海 180

PCL 贪婪投影三角剖分算法【2025最新版】

本博客在学习PCL中的贪婪投影三角算法的基础上,实现了使用彩色点云重建彩色模型的应用案例。博客长期更新,最近一次更新时间为:2025年7月6日。

点云侠的博客 37万+

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Codeforces Round #357 (Div. 2) D Gifts by the List(DFS)

思路:留意到一个性质,如果a想送礼物的对象不是自己或者不是和祖先一样的话那么就可以直接判-1,因为如果a想送给b的话那么必须a到b中间所有都送给b。证明就是比如a->b->c->d,如果a想送给d,b想送给c的话,显然就不成立了。然后就是dfs一波就可以了 #include using namespace std; const int maxn = 1e6+7; int a[maxn];

围巾的ACM博客 500

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Codeforces Round #357 (Div. 2) D. Gifts by the List

题意 给你一个森林 然后给你每个人想要给谁礼物的意愿 这些人给礼物是根据一个列表,他们会从上往下看,看到第一个是他祖先的人,就会给这个人礼物 你需要构造一个列表,满足所有人的意愿。 题解: 直接dfs 如果这个人的意愿不是他自己,或者这个人的意愿和他的父亲不同的话,那么就输出无解,因为这样必然会和他的父亲发生冲突。 为什么呢? 如果a要给b礼物,那么a和b之间的所有人,都必须给b

Ezereal的博客 346

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

[Codeforces Round #357 DIV2D (CF681D)] Gifts by the List

题意nn个人,mm条边的有向无环图,每个顶点至多一个入边,一个点的祖先定义为自己和所有通向自己的点。给出nn个人希望送给礼物的祖先aia_i,构建一个定点序列,对每个点,序列中作为ii的祖先的最左边的定点必须等于aia_i,若不存在这样的序列输出−1-1题解首先答案序列如果存在,一定是给出的ai{a_i}中不同的所有点。拓扑序最靠后的出现在ai{a_i}中的点,我们会把它放在最前面,让他的所有儿子给

ztx 382

Codeforces Round #357 (Div. 2)-D. Gifts by the List

原题链接 我的思路是把 appropriate lists上的数字通过题中给出的家族图确定关系(若a必须在b前面在a->b),再通过拓扑排序输出。 接下里就是建立appropriate lists上数字与数字之间的关系。先建立家族关系图(若a是b的父亲则a->b),并且确定各个点的入度。建立数组p[i], p[i]是i想要送礼物的人。遍历1到n所有的点,若m的入度为零则从m开始深搜,用or

L. 595

Codeforces Round #497 (Div. 2)D题详解

D. Pave the Parallelepiped D题做法实际上很显然,你只要保证你选出来的三个数a,b,c能和A,B,C一一对应(这里的对应是指前者是后者的因子),但是由于A,B,C这三个数有可能有共同的因子。那么在选择的时候需要进行容斥来排除重复选择的情况。然而容斥很麻烦。。 其实我们不用想的那么复杂,首先我们可以画一幅图。 因子的种类实际上可以分成图上7类,你只要挑出3类,A,...

qq_34921856的博客 795

CodeForces - 1008D - Pave the Parallelepiped (容斥原理+重复组合公式+状态压缩+思维)

题目链接: http://codeforces.com/problemset/problem/1008/D 前置知识: 1.容斥原理:(见百度百科) https://baike.baidu.com/item/%E5%AE%B9%E6%96%A5%E5%8E%9F%E7%90%86/10146840?fr=aladdin 2.重复组合公式(刘汝佳—算法竞赛入门经典) 有n个不同元素,每个...

QDU_ZXF的博客 3578

Codeforces Round #497 (Div. 2)

Codeforces Round #497 (Div. 2)(java) A Romaji B Turn the Rectangles C Reorder the Array Codeforces Round #497 (Div. 2)(java) 刷题笔记 这次区分度不太好,DIV2只有前20人能做出一道D或者E,后面几千人全都是三题….. A Romaji prob...

codeJxwww's blog 650
上一篇: Network-POJ3694并查集+LCA
下一篇: Codeforces 842C - Ilya And The Tree 【树上DFS】
sega_handsome
博客等级 码龄10年 7粉丝 164原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值