Search Algorithm introduction

A* Search Algorithm A* Search Algorithm 写在前面:第一次写博客,以后想把遇到的有意思的算法或者小知识记录下来。纯原创,部分图片来自课堂PPT,出自UCR,CS170课件。转载请声明出处。 算法简介 A* Search 是一种启发式搜索算法,该算法内置一个函数来表达当前状态和目标状态的差值。举个栗子,8-puzzle问题(一个游戏,目标是将对应数字的版块放到对应位置)。当前状态是下图 目标状态: ... 阅读详情

search algorithm

Since in the assignment 7, we have a search problem which is a sudoku, I decided to write something about search algorithm.

1.Summary

When it comes to search algorithm, everyone would think about DFS(depth first search) and BFS(breadth first search).The difference between them is that DFS is a way to search to the bottom and then back search for another path, but when we use BFS, the first solution we find is the shortest path.Now,let’s go deeper to these problems.

2.DFS

When we use DFS,there is a fixed pattern:search,suppose,recall.something like this way:

for(int i=0;i<n;i++)      //search
{
  if(blablabla)
  {
    graph[i]=i;      //suppose
    dfs();
    graph[i]=0;       //recall
  }
}  

Now,let try a simple problem:

four-color problems(code_vss P1116)

DESCRIPTION:
给定N(小于等于8)个点的地图,以及地图上各点的相邻关系,请输出用4种颜色将地图涂色的所有方案数(要求相邻两点不能涂成相同的颜色)
数据中0代表不相邻,1代表相邻
INPUT DISCRIPTION:
第一行一个整数n,代表地图上有n个点
接下来n行,每行n个整数,每个整数是0或者1。第i行第j列的值代表了第i个点和第j个点之间是相邻的还是不相邻,相邻就是1,不相邻就是0.
我们保证a[i][j] = a[j][i] (a[i,j] = a[j,i])
OUTPUT DISCRIPTION:
染色方案数

SAMPLE INPUT
8
0 0 0 1 0 0 1 0
0 0 0 0 0 1 0 1
0 0 0 0 0 0 1 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
1 0 1 0 0 0 0 0
0 1 0 0 0 0 0 0
SAMPLE OUTPUT
15552

SOLUTION
This isn’t a complicated problem.So you can simply understand when you read the code blow:

#include<iostream>
using namespace std;
bool map[10][10]={0};
int color[10]={0};
int count=0;
int n;
/* check whether the color has been used for the former one */
bool check(int index,int num)  
{
    for(int i=1;i<num;i++)
    {
        if(map[num][i])
        {
            if(color[i]==index)
            {
                return false;
            }
        }
    }
    return true;
}
/* the main process --recursion */
void dfs(int num)
{
    if(num==n+1)
    {
        count++;
        return;
    }
    for(int i=1;i<=4;i++)
    {
        if(check(i,num))
        {
            color[num]=i;
            dfs(num+1);
            color[num]=0;
        }
    }
    return;
}
int main(void)
{
    //int n=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>map[i][j];
        }
    }
    dfs(1);
    cout<<count<<endl;
} 

3.BFS

As the passage says above, BFS can find the shortest path easily(which means you don’t need to compare which is the shortest manually).The realization of BFS need to use queue.First,find the first tier and push them into the queue.Then,pick out the first one,find the nodes linked with this node and put them into the queue.Finally finish your search when you find you reach the final location.For details,you can see this(this blog explain the problems with picturesm,which is quite suitable for those who just started to learn bfs)


maze problem(poj 3849)

DESCRIPTION
定义一个二维数组N*M(其中2<=N<=10;2<=M<=10),如5 × 5数组下所示:

int maze[5][5] = {          
      0, 1, 0, 0, 0,   
      0, 1, 0, 1, 0,   
      0, 0, 0, 0, 0,  
      0, 1, 1, 1, 0,  
      0, 0, 0, 1, 0  };  

它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。入口点为[0,0],既第一空格是可以走的路。Input一个N × M的二维数组,表示一个迷宫。数据保证有唯一解,不考虑有多解的情况,即迷宫只有一条通道
Output
左上角到右下角的最短路径

Sample Input
0 1 0 0 0
0 1 0 1 0
0 0 0 0 0
0 1 1 1 0
0 0 0 1 0
Sample Output
(0, 0)
(1, 0)
(2, 0)
(2, 1)
(2, 2)
(2, 3)
(2, 4)
(3, 4)
(4, 4)
My solution

#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
int dx[4] = { 0,-1,1,0 };
int dy[4] = { 1,0,0,-1 };
typedef struct unit {
    int x;
    int y;
    int pre;
}unit;
vector<unit>Data;
int answer[30];
int map[5][5];
void init()
{
    for (int i = 0;i<5;i++) {
        for (int j = 0;j<5;j++) {
            cin >> map[i][j];
        }
    }
}
void print(int num)
{
    int count = 0;
    unit* index = &Data[num];
    do {
        answer[count] = index->x;
        answer[count + 1] = index->y;
        count += 2;
        if (index->pre == -1) {
            break;
        }
        else {
            index = &Data[index->pre];
        }
    } while (1);
    for (int i = count - 2;i >= 0;i -= 2)
    {
        cout << '(' << answer[i] << ", " << answer[i + 1] << ')' << endl;
    }
    cout << "(4, 4)" << endl;
}

void bfs()
{
    unit* p0 = new unit;
    p0->pre = -1;
    p0->x = 0;
    p0->y = 0;
    Data.push_back(*p0);
    map[0][0] = 1;

    int currX = 0, currY = 0, x, y, now = 0, last = 1;
    do {
        currX = Data[now].x;
        currY = Data[now].y;
        for (int i = 0;i<4;i++) {
            x = currX + dx[i];
            y = currY + dy[i];
            if (x == 4 && y == 4) {
                print(now);
                exit(0);        //find the path
            }
            if (x <= 4 && x >= 0 && y <= 4 && y >= 0) {
                if (map[x][y] != 1) {
                    unit* index = new unit;
                    index->pre = now;
                    index->x = x;
                    index->y = y;
                    map[x][y] = 1;
                    Data.push_back(*index);
                    last++;
                }
            }
        }
        now++;
    } while (now!=last);
}
int main(void)
{
    init();
    bfs();
    return 0;
}

4.Final

Since I am a beginner in studying Search algorithm, I didn’t have to much thinking about this.But finally,I’d like to give you some oj problems and my own solutions you can refer to.
Superprime(vijos P1359)
my code:

#include<iostream>
using namespace std;
int n=0,num=0;
bool check(int num)
{
    if(num==1)
    return false;
    for(int i=2;i*i<=num;i++)
    {
        if(num%i==0)
        {
            return false;
        }
    }
    return true;
}
void dfs(int pos)
{
    if(pos==n+1)
    {
        cout<<num<<endl;
        return;
    }
    for(int i=1;i<=9;i++)
    {
        num=num*10+i;
        if(check(num))
        {
            //index*=10;
            //count++;
            dfs(pos+1);
            //index/=10;
        }
        num=(num-i)/10;
    }
}
int main(void)
{

    cin>>n;
    dfs(1);

} 

Sukodu(vijos Tongji2016c++ domain P4)
attention:if you search directly,you will probably out of time.So you need to pruning in some ways.
my code:

#include<iostream>
using namespace std;
int graph[9][9]={0};
//bool able[10]={0};
//can't use global variables for it may
//change the value when you search for the 
//next step,and when you return,the value in
//this global variable may not be the original one
//so the solution is to pass a local variable to 
//the `check` function 
int result=0,count=0;
int weight[9][9]=
{
    1,1,1,1,1,1,1,1,1,
    1,3,3,3,1,3,3,3,1,
    1,3,6,3,6,3,6,3,1,
    1,3,3,3,1,3,3,3,1,
    1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,
    1,1,1,9,1,9,1,1,1,
    1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,
};
void calculate()
{
    int index=0;
    for(int i=0;i<9;i++)
    {
        for(int j=0;j<9;j++)
        {
            index+=(weight[i][j]*graph[i][j]);
        }
    }
    if(index>result)
    {
        result=index;
    }
}
int check(int x,int y,bool able[10])
{
    for(int i=1;i<10;i++)
    {
        able[i]=true;
    }
    for(int i=0;i<9;i++)
    {
        able[graph[i][y]]=false;
        able[graph[x][i]]=false;
    }
    x=x/3*3;
    y=y/3*3;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            able[graph[x+i][j+y]]=false;
        }
    }
    int a=0;
    for(int i=1;i<10;i++)
    {
        if(able[i])
        {
            a++;
        }
    }
    return a;
}
void dfs()
{
    bool able[10];
    int xx=-1,yy,index,min=10;
    for(int i=0;i<9;i++)
    {
        for(int j=0;j<9;j++)
        {
            if(graph[i][j]) continue;
            index=check(i,j,able);
            if(index==0)    return;
            if(index<min)
            {
                min=index;
                xx=i;
                yy=j;
            }
        }
    }
    if(xx==-1)
    {
        count++;
        calculate();
        //display();
        return;
    }
    check(xx,yy,able);
    for(int i=1;i<10;i++)
    {
        if(able[i])
        {
            graph[xx][yy]=i;
            dfs();
        }
    }
    graph[xx][yy]=0;
}
int main(void)
{
    for(int i=0;i<9;i++)
    {
        for(int j=0;j<9;j++)
        {
            cin>>graph[i][j];
        }
    }
    dfs();
    if(result)
    {
        cout<<result<<endl;
    }
    else 
    cout<<"-1"<<endl;
}
[Introduction AI] Local Search::Genetic Algorithm(遗传算法) 本文为 BJUT 2021 Fall Introduction to AI 的读书笔记; 课程教材为:Artificial Intelligence: A Modern Approach; Cover: Photo by National Cancer Institute on Unsplash Genetic Algorithm #school_notes #algorithm/search Genetic AlgorithmGenetic AlgorithmIntroductionEncodings(编 阅读详情

相关推荐

《Thinking In Algorithm》05.Hash Tables(哈希表)

1.Hash table Not to be confused with Hash list or Hash tree. 什么是hash table ? 哈希表(Hash table,也叫散列表),是根据关键码值(Key value)而直接进行访问的数据结构。也就是说,它通过把关键码值映射到表中一个位置来访问记录,以加快查找的速度。这个映射函数叫做散列函数,存放记录的数组叫做散列

5071

搜索算法--Search Algorithm

在java中,我们常用的查找有四种: 1) 顺序(线性)查找 2) 二分查找/折半查找 3) 插值查找 4) 斐波那契查找 一、线性查找 在数组中进行查找,找到返回下标,找不到返回-1 //线性查找 public static int seq(int[] array, int data) {...

YZG ' BLOG 1141

数学建模竞赛必备:LaTeX论文模板从入门到精通实战指南

在学术写作与科技竞赛中,遵循规范的论文格式是专业性的重要体现。LaTeX作为一种专业的文档排版系统,其核心原理在于通过预定义的模板和宏命令,将内容与格式分离,实现自动化、高质量的排版。这一技术价值在于能显著提升写作效率,确保格式一致性,并避免手动调整带来的低级错误。在数学建模、学术论文撰写等应用场景中,一个优秀的LaTeX模板能帮助作者将精力聚焦于模型构建与内容创作本身。本文以数学建模竞赛为具体切入点,深入解析如何高效利用“论文模板”和“LaTeX模板”这一组合工具,涵盖从环境搭建、模板获取、结构解析到内容

weixin_30598225的博客 421

Lesson 3 Search algorithms

Search algorithms是最平常的算法:在某个数据结构中 查询 某个数据, 或者 search 某个值。 search 是探寻的意思,不仅可以是在已经的数据中查询某个结果,也可以是在黑暗中寻找某个答案。 search是探寻,是无数次的尝试,所以肯定是 Iterative algorithms. 1.在已知中查询某个数据。 eg:在一个字符串中查找某个字符。 def sear

u011273929的专栏 518

NFC门禁卡复制全解析:从M1卡到UID卡的攻防实践

本文深入解析了NFC门禁卡的安全机制与攻防实践。从M1卡基于Crypto1算法的原理漏洞讲起,详细阐述了利用Proxmark3等工具进行侦听、破解密钥及使用UID卡进行复制的完整攻击链条。同时,为防御方提供了从升级CPU卡、启用全扇区认证到部署多因子验证的系统性防护策略,旨在帮助管理员构建更稳固的物理安全防线。

weixin_29182481的博客 1401

基于单目视觉的四旋翼定点降落——如何通过mavros控制pixhawk(二)

    一直拖了这么久没有更新,怪我太懒啦~~~ 今天要特别感谢舒仔仔同学,我的好队友帮我写了这篇博文。这篇文章主要讲了如何通过mavros来控制pixhawk。硬件逻辑是这样子,我们先搞一个odroid(土豪上TX2),再用usb线将odroid与pixhawk连接。所以,odroid发送控制指令来控制pixhawk飞行。pixhawk与外界的通信协议是mavlink。ROS下面有个包叫mavr...

zhengyuxin0507的博客 1万+

数据结构与算法---查找算法(Search Algorithm)

查找算法介绍 在java中,我们常用的查找有四种: 顺序(线性)查找 二分查找/折半查找 插值查找 斐波那契查找 1)线性查找算法 示例: 有一个数列: {1,8, 10, 89, 1000, 1234} ,判断数列中是否包含此名称【顺序查找】 要求: 如果找到了,就提示找到,并给出下标值。 思路:将数列遍历匹配,就是用for循坏遍历,if匹配数据,找到下标值输出。 ...

weixin_30701575的博客 413

RGB接口电容触摸屏驱动(一)模块介绍

RGB接口电容触摸屏驱动(一)模块介绍

杰克拉力船长个人博客 7877

dfs深度优先搜索_图的深度优先搜索(DFS)

dfs深度优先搜索Depth First Search (DFS) is an algorithm that searches a graph/tree, in a depth-wise manner. 深度优先搜索 ( DFS )是一种以深度方式搜索图/树的算法。 There are many ways through which we can traverse through a graph...

从零开始的教程世界 4354

WGS-84 ECEF ENU 坐标系学习记录

地球坐标系固定在地球上而随地球一起在空间做公转和自转运动,因此地球上任一固定点在地球坐标系的坐标就不会由于地球旋转而变化。地心地固直角坐标系和大地坐标系都属于这种坐标系。 一、 几种坐标系 地心地固直角坐标系(ECEF)坐标系 其原点为地球的质心,x轴延伸通过本初子午线(0度经度)和赤道(0deglatitude)的交点。 z轴延伸通过的北极(即,与地球旋转轴重合)。 y轴完成右手坐标系,穿...

YYshuangshuang的博客 1万+

2026年沐曦集成电路数字IC笔试试卷带答案

本文摘要: 这是一份数字IC设计笔试模拟题,包含单选题、波形分析、多选题和代码设计题。重点考察ASIC设计流程(如逻辑综合将RTL转为门级网表)、时序分析(建立时间余量计算)、跨时钟域处理(格雷码应用)、复位机制、状态机设计等核心知识点。涉及沐曦特色考点如GPU架构(SIMT模型)、国产GPU芯片(曦云C系列)及MXMACA软件栈。代码题要求实现50%占空比三分频电路,综合考察Verilog设计能力。试题强调PPA优化、低功耗技术等工程实践要点,覆盖数字IC前端设计全流程核心内容。(149字)

Open 259

optimal_binary_search_tree introduction to algorithm 3rd, example 15.5

算法导论 第三版 15.5动态规划问题 // optimal_binary_search_tree introduction to algorithm 3rd, example 15.5 #include #include #include #include #include #include #include #include #include

SalmonRun的专栏 938

基于深度学习的推荐系统设计与实现

基于深度学习的推荐系统设计与实现 作者:禅与计算机程序设计艺术 / Zen and the Art of Computer Programming / TextGenWebUILLM 基于深度学习的推荐系统设计与实现 关键词:深度学习, 推荐系统, 用

AI天才研究院 1079

Introduction to Algorithms (Binary Search Trees, BST Sort)

 Runway Reservation System Airport with single runway Reservations for future landings Reserve request specifies landing time t Add t to the set R if no other landings are scheduled within k minu...

Da_tianye的博客 422

下载MNIST数据集并使用python将数据转换成NumPy数组(源码解析)

下载MNIST数据集并使用python将数据转换成NumPy数组首先来分析init_mnist函数接下来继续分析load_mnist函数实现数据集转换的python脚本的代码显示MNIST图像并确认数据 下载MNIST数据集并将数据转换成NumPy数组的Python脚本里面最重要的就是load_mnist函数,其他项目想要调用数据集的话,就可以调用load_mnist函数,得到一个字典类型的数据,字典的值是一个Numpy数组。 这些过程是如何实现的,现在开始逐字逐句分析源码: 在load_mnist函数中第

及时总结 4268

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Introduction to Algorithms (Breadth-First Search)

Graph Search Explore a graph find a path from start vertex s to the desired vertex visit all vertices or edges of graph or only those reachable from s Applications web crawling social networking ...

Da_tianye的博客 333

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Notes of Reading Introduction to Algorithm —— Heapsort

Heaps A binary heap can be stored in an array. If we know the index of a node, we can easily work out the indices of its parent, left child and right child. Therefore, we have the three functions to g...

Yuzhen_Feng的博客 353

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

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Introduction to Algorithm 第二章第三节

2.3-4   其中D(n)为分解问题成子问题所需要的时间 C(n)为合并子问题的解成原问题的解   2.3-5 伪代码 Binary_Search(L, R, A, key) mid = (L + R) / 2 if(A[mid] == key) return mid if(L == R) return false if(A[mid...

DickensTone的博客 203

【论文笔记】Efficient Progressive Minimum k-Core Search

INTRODUCTION 对于这个问题有几种启发式算法,但是它们依赖于简单的评分函数,并且与最优解相比,不能保证结果子图的大小。我们的实证研究还表明,他们的结果子图的大小在实践中可能很大。在本文中,我们开发了一个有效的渐进式算法,即PSA,以在结果质量和搜索时间之间提供良好的平衡。设计了新的最小k核搜索的上下界技术。 与k核模型相关的问题已在文献中得到深入研究,现有的许多研究工作主要集中在最大k核计算上,其目的是寻找满足k核约束的最大诱导子图。 然而,在某些情况下,尤其是当涉及一个或一组查询顶点时,用户可.

HNUJSY 603

[Stanford Algorithms: Design and Analysis, Part 2] c17-21 greedy algorithm | prim MST

Specific topics in Part 2 include: greedy algorithms (scheduling, minimum spanning trees, clustering, Huffman codes), dynamic programming (knapsack, sequence alignment, optimal search trees, short...

weixin_30486037的博客 318

论文阅读:Brain–Computer EMO: A Genetic Algorithm Adapting to the Decision Maker

在进化多目标优化算法执行一定时间后得到的解决方案提交给决策者,决策者根据自己的偏好对解决方案进行排序,并将该排序以成对约束的形式反馈给SVM分类算法进行训练模拟决策者的效用函数,该效用函数将会指导EMOA的搜索优化。在整个优化过程中,决策者还被请求对解决方案进行反馈来更新效用函数,并将算法提供的排序结果与自己的偏好进行对比来选择是否需要进一步的训练。

JiaHao的博客 1499

科研论文结构化解析工作流:四角色AI协作者实战指南

科研论文解析本质上是面向IMRaD结构化文本的信息提取任务,其核心挑战在于通用大模型对学术逻辑模块(Introduction/Methods/Results/Discussion)的语义权重失衡与领域常识缺失。通过将解析任务解耦为职责明确的四个AI协作者,结合轻量级提示词工程、PDF结构化解析与人工可追溯校验节点,可在不依赖RAG或模型微调的前提下,实现高保真、可复现、易调试的深度阅读支持。该方案显著提升研究生文献精读效率、工程师竞品技术拆解准确率及技术管理者决策信息密度,尤其适用于CV、NLP与生物信息学

aizexi2652的博客 354

What makes for effective detection proposals? 论文解析

1 介绍(INTRODUCTION) 本文主要对最近的 proposal 检测方法做一个总结和评价。主要是下面这些方法。  2 Detection Proposal 方法(DETECTION PROPOSAL METHODS) 作者将 Detection Proposal 分为两类,grouping method (将图片分为碎片,最后聚合)和 window scoring method (对分成...

weixin_34067102的博客 268

Generative AI System Design Interview (2) -- Gmail Smart Compose

拿gmail 补全作的一个case study。 感觉此书知识结构真挺好的,非常系统,大脑褶皱看平了

Scabbards_的博客 240

Detecting Near-Duplicates for Web Crawling

ABSTRACT 在网页上有很多相似的文档。比如说,两篇文章只有在显示广告这一小部分是互不相同的。但这些不同的地方,对于网页搜索来说,是无关紧要的。因此,如果该网络爬虫技术可以评估最新抓取的网页与之前抓取的网页是否相似,那么它的“质量(类似..就是升级版!性能提升)”就会提升。 在开发一个在数百亿网页栈中检测相似文章的系统过程中,我们做了两项研究贡献。第一个,我们证明了Charikar的指纹识

lafeedfh的专栏 1460
上一篇: cocos study notes-Scene
下一篇: C++实现vector
lovesnowbest
博客等级 码龄10年 6粉丝 43原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值