关于网络神经性的C程序 [英] C program on net neurality

查看:94
本文介绍了关于网络神经性的C程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Quote:

神经网络在机器学习领域非常受欢迎。神经网络由多个层组成。它有一个输入层,您可以在其中输入参数x(程序的输入)。输入然后通过多个隐藏层,最后在最后一层获得一个输出,称为输出层。



我们有一个非常简单的神经网络,包括N个隐藏层。每层包含一个神经元。每个神经元都有两个与之相关的值:wi和bi,表示神经元的重量和偏差。如果给神经元输入x,它会产生(wi * x)+ bi的输出。



因此,输入x被神经网络转换如下。第一个隐藏神经元取输入x并产生y = w1 * x + b1,它充当第二个神经元的输入。然后,第二个神经元获取输入y并产生z = w2 * y + b2的输出。这种情况一直在发生,你从第N个神经元得到一个输出。



有一些用户,我们想知道他们是否是垃圾邮件。它们具有整数用户ID,范围从minX到maxX(包括两者)。因此,我们将每个用户ID作为输入提供给神经网络的第一层。如果最终输出是偶数,那么该用户不是垃圾邮件发送者,否则,该用户是垃圾邮件发送者。你必须计算非垃圾邮件发送者和垃圾邮件发送者的数量。



输入

输入的第一行包含一个整数T表示测试用例的数量。下面是对T测试用例的描述。

每个测试用例的第一行包含三个以空格分隔的整数N,minX,maxX。

接下来的N行中包含每一行两个以空格分隔的整数wi和bi表示第i个神经元的权重和偏差。

输出

对于每个测试用例,输出两个以空格分隔的整数表示非垃圾邮件发送者的数量和垃圾邮件发送者的数量。



约束

1≤T≤10

1≤N≤105

1≤minX≤maxX≤109

1≤wi,bi≤109

注意我们不能使用数据这里的结构和算法应该只使用基本知识 LOOPS等等。
请有人帮助我找到我的程序中的错误我是编程的新手





我尝试过:



  #include   <   stdio.h  >  
int main()
{
int t;
scanf( %d,& t);
while (t> 0){
int N,minX,manX, w,b,i,z,count = 0 ,countodd = 0 ;
printf( %d%d,countodd,count);

scanf( %d%d%d,& N ,&安培;其minX,&安培; manX的);
int y = minX;
while (minX< = manX){
for (i = 0 ; i< N; i ++){
scanf( %d%d,&安培; W,和b);
y = w * y + b;
}
如果(y%2 == 0
计数++;
else
countodd ++;
minX ++;
}
printf( %d%d,countodd,count) ;
t--;
}
}

解决方案

我会尝试在一些地方放一些空格。在scanf上的数字之间主要是。文本说它们是空格分隔的,因此在scanf上使用格式字符串%d%d%d。你也应该在printfs中使用它们,因为这是你应该根据文本做的。


你的代码的主要问题是尝试读取比以下更多的输入:你正试图读取从 minX manX 的循环中的权重 。相反,你必须读取权重并将它们存储在一个数组中,然后执行迭代,从 minX manX



顺便问一下,为什么ma n X? : - )

Quote:

Neural nets are extremely popular in the Machine Learning domain. A neural net is composed of multiple layers. It has an input layer in which you input the parameter x (the input of the program). The input is then passed through multiple hidden layers, finally getting one output at the final layer, called the output layer.

We have a very simple neural net, which consist of N hidden layers. Each layer contains one neuron. Each neuron has two values associated with it: wi, and bi, denoting the weight and the bias of the neuron. If you give the neuron an input of x, it produces an output of (wi * x) + bi.

Thus, an input x gets transformed by the neural net as follows. The first hidden neuron takes the input x and produces y = w1 * x + b1, which acts as the input for the second neuron. Then, the second neuron takes input y and produces an output of z = w2 * y + b2. This keeps happening and you get a single output at the end from the N-th neuron.

There are some users and we want to find if they are spamming or not. They have integer user-ids, which range from minX to maxX (both inclusive). So we take each of these user-ids and feed it as input to the first layer of the neural net. If the final output is even, then that user is not a spammer, otherwise, the user is a spammer. You have to count the number of non-spammers and spammers.

Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains three space-separated integers N, minX, maxX.
Each of the next N lines contains two space-separated integers wi and bi denoting the weight and the bias of the i-th neuron.
Output
For each test case, output two space-separated integers denoting the number of non-spammers and the number of spammers, respectively.

Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 105
1 ≤ minX ≤ maxX ≤ 109
1 ≤ wi, bi ≤ 109
NOTE WE CANNOT USE DATA STRUCTURES AND ALGORITHMS HERE THAT IT SHOULD BE DONE ONLY USING BASIC KNOWLEDGE OF LOOPS ETC
PLEASE SOMEONE HELP ME IN FINDING THE ERROR IN MY PROGRAM I AM NEW TO PROGRAMMING



What I have tried:

#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t>0){
        int N,minX,manX,w,b,i,z,count=0,countodd=0;
        printf("%d%d",countodd,count);

        scanf("%d%d%d",&N,&minX,&manX);
        int y=minX;
        while(minX<=manX){
            for(i=0;i<N;i++){
                scanf("%d%d",&w,&b);
                y=w*y+b;
            }
            if(y%2==0)
                count++;
            else
                countodd++;
            minX++;
        }
        printf("%d%d",countodd,count);
        t--;
    }
}

解决方案

I would try putting some spaces in a few places. Between the numbers on the scanf primarily. The text says they are space delimited so use a format string of "%d %d %d" on the scanf. You should have them in the printfs too because that is what you are supposed to do according to the text.


The major problem of your code is trying to read more inputs than there are: you are trying to read the weights inside the loop running from minX to manX. Instead you have to read the weights and store them inside an array, then perform the iteration from minX to manX

By the way, why manX? :-)


这篇关于关于网络神经性的C程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆