2013多校联合训练第四场

使用R语言中的NbClust包确定最佳聚类簇数 聚类分析是一种常用的数据分析技术,它将相似的数据点分组成不同的簇。NbClust包是R语言中一个强大的工具,它提供了多种方法来帮助我们确定最佳的聚类簇数。综上所述,使用R语言中的NbClust包可以帮助我们确定最佳的聚类簇数。通过选择适当的聚类算法和评估指标,我们可以更好地理解数据集的结构和模式,并根据需要进行进一步的分析和解释。此外,NbClust包还提供了其他函数和参数,用于执行不同的聚类算法、选择不同的评估指标等。安装完毕后,我们需要加载NbClust包,以便使用其中的函数。函数来确定最佳聚类簇数。 阅读详情

A

求一个字符串的回文子序列个数

很直观的DP但一开始看着这个题目愣了好久……

  scanf("%s" , s + 1);
  n = strlen(s + 1);
  memset(f , 0 , sizeof(f));
  for (i = 1 ; i <= n ; ++ i) f[i][i] = 1;
  for (k = 2 ; k <= n ; ++ k)
  {
    for (i = 1 ; i + k - 1 <= n ; ++ i)
    {
      j = i + k - 1;
      f[i][j] = f[i + 1][j] + f[i][j - 1];
      if (s[i] == s[j])
        f[i][j] ++;
      else f[i][j] += (Q - f[i + 1][j - 1]);
      f[i][j] %= Q;
    }
  }
  printf("Case %d: %d\n" , ++ ca , f[1][n]);

C

先预处理出从某个点出发往四个方向滑的终点位置以及路过能拿到的钥匙

然后就是一个BFS了,边权只有1或0,开deque。

可惜因为没有发现卡墙的问题比赛时没有过这个题TwT

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
#define N 205
#define ULL unsigned long long
int n , m , sx , sy , ex , ey;
char s[N][N];
int dx[] = {1 , -1 , 0 , 0} , dy[] = {0 , 0 , 1 , -1};

pair<int , int>  h[4][N][N] , null = make_pair(-1 , -1);
int kn[N][N], key[4][N][N] , ks , ans;

struct opt
{
  int x , y , p , w , r;
};
deque<opt> q;
int d[N][N][128];
bool f[N][N][128];

void update(int x , int y , int p , int v , int w , int r)
{
  if (!f[x][y][p])
  {
    if (w)
      q.push_back((opt){x , y , p , v + w , r});
    else q.push_front((opt){x , y , p , v + w , r});
  }
}
void BFS()
{
  int i , x , y , w , kk = (1 << ks) - 1;
  ans = 1 << 30;
  q.push_back((opt){sx , sy , 0 , 0 , 0});
  memset(f , 0 , sizeof(f));
  while (!q.empty())
  {
    opt a = q.front(); q.pop_front();
    if (f[a.x][a.y][a.p]) continue;
    f[a.x][a.y][a.p] = 1 , w = d[a.x][a.y][a.p] = a.w;
    x = a.x , y = a.y;
    cout << x <<' ' << y << ' ' << a.p << ' ' << w << endl;
    if (x == ex && y == ey)
    {
      if (a.p == kk)
        ans = min(ans , w);
      i = a.r;
      if (s[x + dx[i]][y + dy[i]] == '#' || h[i][x + dx[i]][y + dy[i]] == null) continue;
      update(h[i][x + dx[i]][y + dy[i]].fi , h[i][x + dx[i]][y + dy[i]] .se , a.p | key[i][x + dx[i]][y + dy[i]] , w , 0 , i);
      continue;
    }
    if (s[x][y] < 4)
    {
      i = s[x][y];
      if (s[x + dx[i]][y + dy[i]] == '#' || h[i][x + dx[i]][y + dy[i]] == null) continue;
      update(h[i][x + dx[i]][y + dy[i]].fi , h[i][x + dx[i]][y + dy[i]] .se , a.p | key[i][x + dx[i]][y + dy[i]] , w , 0 , i);
      continue;
    }
    for (i = 0 ; i < 4 ; ++ i)
      if (h[i][x][y] != null)
        update(h[i][x][y].fi , h[i][x][y].se , a.p | key[i][x][y] , w , 1 , i);
  }
  if (ans == 1 << 30)
    ans = -1;
  printf("%d\n" , ans);
}
void work()
{
  int i , j;
  memset(s , 0 , sizeof(s));
  memset(h , 0 , sizeof(h));
  memset(kn , -1 , sizeof(kn));
  memset(key , 0 , sizeof(key));
  ks = 0;

  for (i = 1 ; i <= n ; ++ i)
    scanf("%s" , s[i] + 1);
  for (i = 1 ; i <= n ; ++ i)
    for (j = 1 ; j <= m ; ++ j)
    {
      if (s[i][j] == 'S')
        sx = i , sy = j;
      if (s[i][j] == 'E')
        ex = i , ey = j;
      if (s[i][j] == 'K')
        kn[i][j] = ks ++;
    }
  for (i = 1 ; i <= n ; ++ i)
    for (j = 1 ; j <= m ; ++ j)
    {
      if (s[i][j] == 'U')
        s[i][j] = 1;
      if (s[i][j] == 'D')
        s[i][j] = 0;
      if (s[i][j] == 'L')
        s[i][j] = 3;
      if (s[i][j] == 'R')
        s[i][j] = 2;
    }
  for (i = n + 1; i > 0 ; -- i)
    for (j = 1 ; j <= m ; ++ j)
    {
      if (i == n + 1) h[0][i][j] = null;
      else
      {
        if (s[i][j] < 4 || s[i][j] == 'E') h[0][i][j] = make_pair(i , j) , key[0][i][j] = 0;
        else if (s[i + 1][j] != '#')
        {
          h[0][i][j] = h[0][i + 1][j];
          key[0][i][j] = key[0][i + 1][j];
          key[0][i][j] |= ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
        else
        {
          h[0][i][j] = make_pair(i , j);
          key[0][i][j] = ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
      }
    }

  for (i = 0 ; i <= n ; ++ i)
    for (j = 1 ; j <= m ; ++ j)
    {
      if (i == 0) h[1][i][j] = null;
      else
      {
        if (s[i][j] < 4 || s[i][j] == 'E') h[1][i][j] = make_pair(i , j) , key[1][i][j] = 0;
        else if (s[i - 1][j] != '#')
        {
          h[1][i][j] = h[1][i - 1][j];
          key[1][i][j] = key[1][i - 1][j];
          key[1][i][j] |= ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
        else
        {
          h[1][i][j] = make_pair(i , j);
          key[1][i][j] = ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
      }
    }
  for (j = m + 1 ; j > 0 ; -- j)
    for (i = 1 ; i <= n ; ++ i)
    {
      if (j == m + 1) h[2][i][j] = null;
      else
      {
        if (s[i][j] < 4 || s[i][j] == 'E') h[2][i][j] = make_pair(i , j) , key[2][i][j] = 0;
        else if (s[i][j + 1] != '#')
        {
          h[2][i][j] = h[2][i][j + 1];
          key[2][i][j] = key[2][i][j + 1];
          key[2][i][j] |= ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
        else
        {
          h[2][i][j] = make_pair(i , j);
          key[2][i][j] = ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
      }
    }
  for (j = 0 ; j <= m ; ++ j)
    for (i = 1 ; i <= n ; ++ i)
    {
      if (j == 0) h[3][i][j] = null;
      else
      {
        if (s[i][j] < 4 || s[i][j] == 'E') h[3][i][j] = make_pair(i , j) , key[3][i][j] = 0;
        else if (s[i][j - 1] != '#')
        {
          h[3][i][j] = h[3][i][j - 1];
          key[3][i][j] = key[3][i][j - 1];
          key[3][i][j] |= ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
        else
        {
          h[3][i][j] = make_pair(i , j);
          key[3][i][j] = ~kn[i][j] ? (1 << kn[i][j]) : 0;
        }
      }
    }
  BFS();
}
int main()
{
  freopen("input.txt","r",stdin);
  while (~scanf("%d%d",&n,&m))
    work();
  return 0;
}

D

SCC缩点之后再枚举割掉的所有入度为0或者出度为0的SCC,更新答案。

代码主要部分不是我写的

#pragma comment(linker,"/STACK:102400000,102400000")

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstring>
using namespace std;
#define N 100010
#define M 200010

int sum,first[N];
struct gtype {
       int x,y,next;
}g[M];

int cas,n,m,a,b,tot,top,cnt,pin[N],pout[N];
int low[N],dfn[N],con[N],stack[N],belong[N];
bool instack[N];

bool cmp(int a, int b) {
     return a>b;
}

void add(int x,int y) {
     sum++;
     g[sum].x = x;
     g[sum].y = y;
     g[sum].next = first[x];
     first[x] = sum;
}

void tarjan(int x) {
    int k;
    dfn[x] = low[x] = ++tot;
    instack[x] = true;
    stack[++top] = x;
    for (int t=first[x];t!=-1;t=g[t].next) {
        int y = g[t].y;
        if (!dfn[y]) {
            tarjan(y);
            low[x] = min(low[x],low[y]);
        }
        else if (instack[y]) low[x] = min(low[x],dfn[y]);
    }
    if (dfn[x]==low[x]) {
        cnt++;
        do {
            k = stack[top--];
            instack[k] = false;
            belong[k] = cnt;
            con[cnt]++;
        }while (k!=x);
    }
}

int main() {
    scanf("%d",&cas);
    for (int tt=1;tt<=cas;tt++) {
        sum = 0;
        memset(first,-1,sizeof(first));
        scanf("%d%d",&n,&m);
        for (int i=1;i<=m;i++) {
            scanf("%d%d",&a,&b);
            add(a,b);
        }

        tot = top = cnt = 0;
        memset(dfn,0,sizeof(dfn));
        memset(low,0,sizeof(low));
        memset(con,0,sizeof(con));
        memset(instack,0,sizeof(instack));
        for (int i=1;i<=n;i++)
            if (!dfn[i]) tarjan(i);

        printf("Case %d: ",tt);
        if (cnt==1) {
           printf("-1\n");
        }
        else {
             long long ans = 0;
             memset(pin,0,sizeof(pin));
             memset(pout,0,sizeof(pout));
             for (int i=1;i<=m;i++) {
                 if (belong[g[i].x] != belong[g[i].y]) {
                    pout[belong[g[i].x]]++;
                    pin[belong[g[i].y]]++;
                 }
             }
             for (int i=1;i<=cnt;i++)
             {
                 if (pin[i]==0)
                 {
                    ans = max(ans, (long long)n*(n-1)-m-(long long)(n-con[i])*con[i]);
                 }
                 if (pout[i]==0)
                 {
                    ans = max(ans, (long long)n*(n-1)-m-(long long)(n-con[i])*con[i]);
                 }
             }
             printf("%I64d\n",ans);
        }
    }
    return 0;
}

G

比赛结束了才被DS提醒是被水了过去……

之前用线段树想的太麻烦,后来才发现可以用数组直接模拟分为了多少段

#pragma comment(linker,"/STACK:102400000,102400000")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define maxn 100010
using namespace std;
typedef long long LL;
int pos[maxn],color[maxn],n,m;
void RD(int& x)
{
  x = 0; char c;
  for (c = getchar() ;!isdigit(c) ; c = getchar()); x = c - '0';
  for (c = getchar() ; isdigit(c) ; c = getchar()) x = x * 10 + c - '0';
}
struct Question
{
    int l,r,id;
    int a;
    friend bool operator < (const Question &a,const Question &b)
    {
        return pos[a.l]<pos[b.l]||(pos[a.l]==pos[b.l]&&a.r<b.r);
    }
}ask[maxn];
bool cmp_id(const Question &a,const Question &b)
{
    return a.id<b.id;
}
bool ff[maxn];
int anss;
void read()
{
    RD(n) , RD(m);
    memset(ff , 0 , sizeof(ff));
    for(int i=1;i<=n;i++)
        RD(color[i]);
    int limit=(int)sqrt(n+0.5);
    for(int j=1;j<=n;j++)
        pos[j]=(j-1)/limit+1;
    for(int i=1;i<=m;i++)
    {
        RD(ask[i].l) , RD(ask[i].r);
        ask[i].id=i;
    }
    sort(ask+1,ask+m+1);
}

void Modify(int i,int add)
{
  if (add == 1)
  {
        int x = color[i];
        ff[x] = 1;
        if (ff[x - 1] && ff[x + 1]) -- anss;
        else if (!ff[x - 1] && !ff[x + 1]) ++ anss;
  }
  else
  {
        int x = color[i];
        ff[x] = 0;
        if (ff[x - 1] && ff[x + 1]) ++ anss;
        else if (!ff[x - 1] && !ff[x + 1]) -- anss;
  }
}
void work()
{
    anss=0;
    for(int i=1,l=1,r=0;i<=m;i++)
    {
        if(r<ask[i].r)
        {
            for(r=r+1;r<=ask[i].r;r++)
                Modify(r,1);
            r--;
        }
        if(r>ask[i].r)
            for(;r>ask[i].r;r--)
                Modify(r,-1);
        if(l<ask[i].l)
            for(;l<ask[i].l;l++)
                Modify(l,-1);
        else if(l>ask[i].l)
        {
            for(l=l-1;l>=ask[i].l;l--)
                Modify(l,1);
            l++;
        }
        ask[i].a=anss;
    }
}
void print()
{
    sort(ask+1,ask+m+1,cmp_id);
    for(int i=1;i<=m;i++)
        printf("%d\n",ask[i].a);
}
int main()
{
  int _; RD(_); while (_--)
    read(),
    work(),
    print();
  return 0;
}

H

每一组hehehehe明显可以分开处理,一段长度为n的hehe....he的方案就是斐波那契的[n/2+1]项,乘起来就ok

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
#define N 15005
#define M 2000005
typedef long long LL;
using namespace std;
char s[N];
int n , m , a[N] , Q = 10007 , f[N] , ca;
void work()
{
  int i , j , ans = 1 , x;
  scanf("%s", s);
  n = strlen(s);
  m = 0;
  for (i = 0 ; i + 3 < n ; ++ i)
    if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'h' && s[i + 3] == 'e')
      a[m ++] = i;
  for (i = 0 ; i < m ; i = j)
  {
    j = i + 1 , x = 1;
    while (a[j] - a[j - 1] == 2)
      ++ j , ++ x;
    ans *= f[x] , ans %= Q;
  }
  printf("Case %d: %d\n" , ++ ca , ans);
}

int main()
{
  f[0] = 1 , f[1] = 2;
  for (int i = 2 ; i <= 10086 ; ++ i)
    f[i] = f[i - 1] + f[i - 2] , f[i] %= Q;
  int _; cin >> _ ; while (_ --)
    work();
  return 0;
}
【30】软考软件设计师——UML类图与用例图满分精讲|下午第3题常考核心 本文是《软件设计师·50讲通关|从零基础到工程师职称》专栏第30篇,聚焦**模块四:应用技术(下午题)第3道高频大题**,UML建模是历年下午必考核心,单题分值稳定10~12分。全文深度拆解两大核心UML图表:**类图**与**用例图**,超详细讲解类图三层结构、可见性修饰符、五大核心关系(泛化/关联/依赖/聚合/组合)的判定标准与绘图规范;吃透用例图参与者、系统边界、三大关系(包含/扩展/泛化)的底层逻辑,搭配独家**关系秒杀口诀、标准绘图模板、真题改错技巧**;全文适配补图、判断关系、分析场景、纠错优化 阅读详情

相关推荐

2013暑期多校联合训练\第四场\Problem H Hehe

水题,发一下,凑数 (*^__^*)               统计一下每一部分的he数就好,规律是斐波那契数列,后来每一个部分相乘得解。 #include using namespace std; int main() { int T,ans,f[5044],i,k,t,l,p=0; char s[10087]; cin >> T; f[1]=2; f[2

JoeJiao 541

用Isaac Sim复现经典案例:手把手教你写Python脚本控制机械臂抓取(附避障算法调试心得)

本文详细介绍了如何使用NVIDIA Isaac Sim仿真系统复现机械臂抓取经典案例,包括Python脚本编写、避障算法调试等关键步骤。通过URDF模型导入、关节控制逻辑实现和RMPFlow避障配置等实战演示,帮助开发者快速掌握机器人仿真技术,特别分享了官方文档未提及的实用调试技巧和性能优化策略。

weixin_30632089的博客 406

HDU 2019 Multi-University Training Contest 4 杭电多校联合训练赛 第四场 1010 Minimal Power of Prime (6623)

Minimal Power of Prime --------------------------------------------分割线------------------------------------------------------------------------------- 跪求用米勒拉宾的大佬们告诉我怎么过题! 在线等!急! -----------------------...

BenFromHRBUST的优快云博客 266

保姆级避坑指南:用Docker在Ubuntu 22.04上部署Isaac Sim 5.1.0,搞定宇树G1仿真环境

本文提供了一份详细的保姆级避坑指南,帮助用户在Ubuntu 22.04上通过Docker部署Isaac Sim 5.1.0,并成功搭建宇树G1仿真环境。文章涵盖了环境准备、Docker与NVIDIA容器工具包的配置、Isaac Sim镜像的定制化拉取与配置,以及宇树G1仿真环境的实战调试,旨在帮助开发者高效解决部署过程中的常见问题。

weixin_33728268的博客 206

USB-Blaster在Win11报错?3分钟搞定驱动兼容性问题(Quartus 21.4实测)

本文针对Windows 11系统下USB-Blaster驱动安装问题,提供了一套快速解决方案。通过优化驱动安装流程、绕过签名验证及设备管理器高级技巧,帮助开发者在3分钟内解决Quartus 21.4的兼容性问题,提升FPGA调试效率。

weixin_30772105的博客 288

2018 多校联盟训练索引

多校联盟主要有 杭州电子科技大学好牛客网举办的比赛,各自十场 牛客多校 牛客多校第一场 牛客多校第二场 杭电多校 杭电多校第一场 杭电多校第二场...

海边拾贝,沧海一粟 420

Android 人像分割实战:OpenCV+YOLOv8+NCNN 三库联动(附 GPU 加速 / 内存优化全方案)

本文详细介绍了在Android项目中集成OpenCV+YOLOv8+NCNN实现实时人像分割的技术方案。主要内容包括:项目环境搭建(配置NDK、添加Native模块)、核心库文件集成(OpenCV、NCNN、YOLOv8模型)、JNI接口设计与实现(Kotlin层调用C++算法)。通过Camera API获取图像数据,使用YOLOv8进行人体检测,结合NCNN高性能推理框架实现人像分割处理,最终将原始画面与分割结果(背景透明)同时显示在Android界面上。该项目采用多技术栈协同工作,OpenCV负责图像处

FJN110的博客 232

HDOJ多校联合第四场

B题:   C题:仅由'A','G','C','T',4个字母组成,给定一个字符串S,|S| 分析:dp+状态压缩 反正我不会这题,也是看了羊神的代码之后才明白这题的思路 下面说说我的理解吧:   由于|S|长度最大为15,所以用一个二进制编码表示是哪些位置上的字母构成LCS,并求相应的数目。 dp[0][st],dp[1][st]记录的是相应字母构成LCS时,T可能的数目,然后一

rootial的专栏 480

手把手教你学Simulink--移动机器人多轮协同场景实例:基于Simulink的双轮差速PMSM轮毂电机协同驱动仿真

本文介绍了基于Simulink的双轮差速PMSM轮毂电机协同驱动仿真系统。针对移动机器人存在的电机参数不一致、负载分配不均等问题,提出主从同步+力矩补偿的协同控制策略。通过搭建包含运动学模型、PMSM电机模型和矢量控制器的仿真系统,实现了速度同步误差<0.005m/s、轨迹跟踪误差<0.8cm、能耗降低12.5%的优化效果。文章详细阐述了建模步骤、核心算法实现和性能验证,为移动机器人动力系统设计提供了实用参考方案。

MHD0815的博客 131

如何在白平衡标定种构建不同类型的白平衡色温坐标系

以各家芯片方案的白平衡色温坐标系为切入点,详细介绍了各家芯片色温坐标系构建的理论依旧;并解析了不同色温坐标系下的物理含义,提提出了多种不同的色温坐标系

大熊 959

2012多校第四场总结

本场比赛我发挥的还算正常,贡献了三个题: 一个线段树、一个哈希题、一个期望DP 大一的牛哥贡献了一个矩阵乘法的题目,这个题A的人还蛮少的,赞一个,总共四个,还好,总算也进了第一版 但是,另有两个几十个人做的题都没A出来,虽然有一个题可以水过,但是我最后时刻太匆忙,连暴力搜索的代码都敲错了(这或许也反映了我代码能力的不足吧) 好的地方就不多说了,因为让人成长、进步的总是那些绊脚石,总是那些不足

努力奋斗才能梦想成真 1259

YOLOv13添加轻量化的EMA模块Faster_EMA,轻量又涨点!map50提升4.56个点,召回率提升9.66!

本文介绍了YOLOv13模型的优化移植方法,通过添加Faster_EMA模块和超参数调整,使模型性能显著提升。主要修改包括:1) 创建新的模型配置文件yolov13-Faster_EMA.yaml;2) 在tasks.py中添加新模块;3) 修改__init__.py和block.py文件,新增Partial_conv3和DropPath类。优化后模型mAP50提升4.56%,召回率提升9.66%,验证了改进方案的有效性。代码实现了局部卷积和随机深度等先进技术,为YOLO系列模型性能优化提供了新思路。

FJN110的博客 2604

hdu 4632 Palindrome subsequence 区间dp 多校联合训练第四场

注意到任意一个回文子序列收尾两个字符一定是相同的,于是可以区间dp,用dp[i][j]表示原字符串中[i,j]位置中出现的回文子序列的个数,有递推关系: 当 第i个字符与第j个字符不相等时有dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1]反之,i和j位置出现的字符相同,那么dp[i][j]=dp[i+1][j]+dp[i][j-1]+1,注意边界特判一下就可

柯安的专栏 1098

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

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

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

HDU 多校联合第四场

比赛的时候各种wa加TLE。。。好纠结。。。 01...至今没搞懂怎么个过程。。。  04 gb用hash过得,后来看了一下标程,复杂度O(n^3),尼嘛,我写个O(n^3*20)的算法就超时。。。! 06  偶始终不明白容斥原理怎么用的。。。估计各位大神是猜的公式,把1/p1 + 1/p2 + ... + 1/pn这个式子写出来后边的就可以猜了。。。 07....很无语的一道题。直接暴力...

weixin_34206899的博客 182

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

hdu 4642 fliping game 多校联合训练第四场

大水题啊,这题 题意是每次要选出一个矩形来进行翻转,矩形的左上角必须是1而且可以任选左上角,但右下角一定要是图的右下角,就是说图的右下角每次都要被取到不停的从0变成一 1变成0,所以先手时图的右下角是一的话,先手必胜 那么就很简单了 #include using namespace std; int main() { int T;cin>>T; while(T--)

柯安的专栏 899

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

多校训练赛题解 第四场 2017 Multi-University Training Contest 4 solutions BY 陈松杨

2017 Multi-University Training Contest 4 solutions BY 陈松杨 发表回复 1001. Big Integer 如果知道k−1k-1k−1个数的个数c1,c2,...,ck−1c_1,c_2,...,c_{k-1}c​1​​,c​2​​,...,c​k−1​​,那么方案数就是: (∑i=1k−1ci)!∏i=1k−1ci!\fr

nankeyimeng的博客 1792

hdu 4639 hehe 多校联合训练第四场

题意比较简单,就是数出有多少个连续的he,当有一个大案是1,二个是2,三个是3,四个是5,五个是8。。。不连续的he段之间是相乘的关系 其实出题的想法是做dp的都拿我这个就比较好玩了,直接递推了,标程题解发如下dp,直接用dp[i]表示0-i这段区间可能变成的不同句子数,首先有dp[i+1]+=dp[i],如果当前位置向后连续4个字符是hehe,那么有dp[i+4]+=dp[i],最后的答案就是

柯安的专栏 821

2017第四场多校联合 hdu6069

题目题意:给你l,r,k,要求(∑i=lrd(ik))mod998244353。题解:首先要知道的知识点是:对于一个知识点N,如果它可以被分解为pa11∗pa22.....pannp_1^{a_1}*p_2^{a_2}..... p_n^{a_n},那么d(N)(即它的因子个数)=(a1+1)∗(a2+1)∗....∗(an+1)d(N)(即它的因子个数)=(a_1+1)*(a_2+1)*....*

开心铁匠铺 341

2015年多校联合训练第四场(Olympiad)hdu5327

题意:找区间美丽数(自身有不同数字组成的数,如123是,100不是)的个数 思路:打表#include <bits/stdc++.h> #define LL long long using namespace std; int a[1001005]; int n; int f[100005]; int sum[100005]; int flag[10];void init() { for(

逍遥小章 965

2018-2019赛季多校联合新生训练赛第四场

问题 A: 数一数时间限制: 1 Sec 内存限制: 128 MB 题目描述 星期天早上,小明开始做数学家庭作业。因为小明成绩很优异,觉得题目太简单了,思考出道难点的数学题去学校考考同学,他注意到:数学书的第10页和第11页在同一张纸上,但第11页和第12页不在同一张纸上。 哈哈,题目有了,请问数学书的第x页到第y页共有多少张纸呢? 例如:该书的第81页到第92页,共有7张纸。 输入一行两个数x...

休矣1998的博客 1729

2016多校联合训练赛 第四场1012 Bubble Sort hdu 5775

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5775 题意:给出一个1~n的排列,在给定的冒泡排序之后,问对于每个元素,它到达的最右和最左的差值是多少。 思考:对于某一位数字,最右位置是max(i, a[i]),即初始位置或最终位置,最左位置为向左移动的次数,即比它小但在它右边的数的个数。那么问题的关键就转移到了逆序数,树状数组求解即可。总复杂度

你是我天边最美的云彩~~ 332

2015年多校联合训练第四场(Problem Killer)hdu5328

题意: 求最大等差或等比数列的长度 思路: 开始用二分,WA暴了,后来发现我用的等差数列公式有问题 (a[i]+a[j])*(j-i+1)/2,等差数列一定满足这个公式,但满足这个公式的不一定是等差数列,我sb了。。。。。 还有就算等比数列a[i+1]/a[i] == a[i]/a[i-1],也是sb了,这个会引起精度丢失,应该a[i]^2 = a[i-1]*a[i+1]; ……. 正

逍遥小章 814

2016多校联合训练赛 第四场1001 Another Meaning hdu 5763

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5763 题意:给定一个串,对于该串的文本可以进行转义,即理解出第二种意思。给一个文本,求出对该文本的理解数。 做法:KMP + DP 另dp[i]表示以第i个字符结尾的意义数,则末尾不能转义时,dp[i] = dp[i - 1],可以转义时dp[i] = dp[i - 1] + dp[i - l]。

你是我天边最美的云彩~~ 178

牛客网暑期多校训练赛第四场 G题 Maximum Mode

题目链接   题意: 给了一串数字,定义数字的Mode值是出现次数最多的数字,现在可以恰好删除m个数字,Mode值只允许为一个值,求出最大的Mode值为多少,否则输出-1。   思路: 要让某一个值是Mode,需要把比它出现次数多的和与它次数相同的至少降低到比它出现的次数少1。 基于这个想法,可以先处理出每个值出现的次数并将它按照次数的降序来排序。然后O(N)的跑一次,将每个值作为M...

Timeclimber 451

2020杭电多校第四场 Equal Sentences(DP)

Problem Description Sometimes, changing the order of the words in a sentence doesn’t influence understanding. For example, if we change “what time is it”, into “what time it is”; or change “orz zhang three ak world final”, into “zhang orz three world ak fi

tomjobs的博客 601
上一篇: 2013多校联合训练第三场
下一篇: 2013多校联合训练第五场
Sd_无心插柳
博客等级 码龄14年 39粉丝 38原创
评论 6
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值