小编Ado*_*orn的帖子

神经网络不学习 - MNIST数据 - 手写识别

我写了一个神经网络程序.它适用于Logic Gates,但是当我尝试使用它来识别手写数字时 - 它根本就不会学习.

请找到以下代码:

//这是一个神经元; 为了理解剩余的代码,这可能是必要的

typedef struct SingleNeuron
{
    double                  outputValue;
    std::vector<double>     weight;
    std::vector<double>     deltaWeight;
    double                  gradient;
    double                  sum;
}SingleNeuron;
Run Code Online (Sandbox Code Playgroud)

然后我初始化网.我将权重设置为-0.5到+0.5之间的随机值,总和为0,deltaWeight为0

然后是FeedForward:

for (unsigned i = 0; i < inputValues.size(); ++i)
{
    neuralNet[0][i].outputValue = inputValues[i];
    neuralNet[0][i].sum = 0.0;
    //  std::cout << "o/p Val = " << neuralNet[0][i].outputValue << std::endl;
}

for (unsigned i = 1; i < neuralNet.size(); ++i)
{
    std::vector<SingleNeuron> prevLayerNeurons = neuralNet[i - 1];
    unsigned j = 0;
    double thisNeuronOPVal = 0;
    //  std::cout << std::endl; …
Run Code Online (Sandbox Code Playgroud)

c++ gradient machine-learning image-processing neural-network

22
推荐指数
1
解决办法
2029
查看次数

打印分区表 - C程序

我试图使用C编程语言打印分区表,一切似乎工作正常:打开和阅读,但我不明白为什么它是打印垃圾值.

这是代码:

struct partition
{
    unsigned char drive;
    unsigned char chs_begin[3];
    unsigned char sys_type;
    unsigned char chs_end[3];
    unsigned char start_sector[4];
    unsigned char nr_sector[4];
};

int main()
{
    int gc = 0, i = 1, nr = 0, pos = -1, nw = 0;
    int fd =0;
    char  buf[512] ;
    struct partition *sp;
    printf("Ok ");

    if ( (fd = open("/dev/sda", O_RDONLY | O_SYNC )) == -1)
    {
         perror("Open");
         exit(1);
    }
    printf("fd is %d \n", fd);

    pos = lseek (fd, 0, SEEK_CUR); …
Run Code Online (Sandbox Code Playgroud)

c linux filesystems operating-system partitioning

9
推荐指数
1
解决办法
5096
查看次数

在Windows上安装Theano - DLL加载失败

我想在Windwos 8上安装Theano

遵循了这些步骤.

我尝试使用测试:

import numpy as np
import time
import theano

print('blas.ldflags=', theano.config.blas.ldflags)
A = np.random.rand(1000, 10000).astype(theano.config.floatX)
B = np.random.rand(10000, 1000).astype(theano.config.floatX)
np_start = time.time()
AB = A.dot(B)
np_end = time.time()
X, Y = theano.tensor.matrices('XY')
mf = theano.function([X, Y], X.dot(Y))
t_start = time.time()
tAB = mf(A, B)
t_end = time.time()
print("NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" % (
np_end - np_start, t_end - t_start))
print("Result difference: %f" % (np.abs(AB - …
Run Code Online (Sandbox Code Playgroud)

python dll installation pdb theano

6
推荐指数
2
解决办法
6182
查看次数

OpenCL Theano - 如何强制禁用CUDA?

经过一系列的努力,我已将Theano安装在配备AMD显卡的机器上 - Radeon HD 5450 (Cedar).

现在,考虑以下代码.

import numpy
import theano
import theano.tensor as T
rng = numpy.random

N = 400         #number of samples
feats = 784     #dimensionality of features
D = (rng.randn(N, feats), rng.randint(size=N, low=0, high=2))
training_steps = 10000

# theano symbolic variables
x = T.matrix("x")
y = T.vector("y")
w = theano.shared(rng.randn(784), name="w")
b = theano.shared(0., name="b")

print("Initial Model:")
print(str(w.get_value()) + " " + str(b.get_value()) )

p_1 = 1/(1 + T.exp(-T.dot(x, w) - b))       # probability of target …
Run Code Online (Sandbox Code Playgroud)

machine-learning opencl neural-network theano

6
推荐指数
1
解决办法
1847
查看次数

计算最终市场分布 - 竞争性规划

我在练习竞争性编程时遇到了以下问题.我手动解决了,有点设计方法,但我的答案是错误的,我无法想象如何扩展我的方法.

问题:

N个咖啡连锁店正在通过激烈的广告战争争夺市场份额.每天,一定比例的客户将被说服从一个链转换到另一个链.

给出了当前的市场份额和每日客户转换的概率.如果广告永远存在,那么市场份额的最终分配是什么?

假设:总市场份额为1.0,客户转换的概率独立于其他客户和天数.

例如:2个咖啡连锁店:A和B市场份额A:0.4市场份额B:0.6.

每天,客户从A切换到B的概率为0.2每天,客户从B切换到A的概率为0.1

input: market_share=[0.4,0.6],

switch_prob = [[.8,.2][.1,.9]]

output: [0.3333 0.6667]

直到这里的一切都是问题的一部分,我没有形成例子或假设,他们给出了问题.

My_attempt:根据我的理解,切换概率表示从A切换到B的概率.

因此,

market_share_of_A = current_market_share - lost_customers + gained_customers and 
marker_share_of_B = (1 - marker_share_of_A)

iter_1: 
    lost_customers = 0.4 * 0.8 * 0.2 = 0.064
    gained_customers = 0.6 * 0.2 * 0.1 = 0.012
    market_share_of_A = 0.4 - 0.064 + 0.012 = 0.348
    marker_share_of_B = 1 - 0.348 = 0.652

iter_2:
    lost_customers = 0.348 * 0.1 * 0.2 = …
Run Code Online (Sandbox Code Playgroud)

algorithm math distribution probability

6
推荐指数
1
解决办法
427
查看次数

operator delete - 如何实现?

我知道在正常情况下如何处理内存解除分配.我的情况略有不同.

我正在实现自己的内存池.我希望我班级的客户能够接近分配和解除分配的一般方法.

inline void* operator new(size_t dead_param, CPool&  objPool)
{
    return objPool.Allocate();
}
Run Code Online (Sandbox Code Playgroud)

我有这个全局函数,所以我班级的用户可以简单地调用

Base baseObj = new (poolObj)Base2();

现在我不知道如何调用析构函数?我清楚没有想法

虽然我有全局运算符删除

inline void operator delete(void* ptr, CPool& objPool)
{
    objPool.DeAllocate(ptr);
}
Run Code Online (Sandbox Code Playgroud)

请指导..如何从客户端代码中调用此函数?用户端语法的变化很小.另外请注意,我不希望我的代码的用户实施operator newoperator delete并呼吁AllocateDeAllocate从那里.

c++ memory-management new-operator delete-operator

5
推荐指数
0
解决办法
610
查看次数

如何规范化数字序列?

我正在处理用户行为项目.根据用户交互,我得到了一些数据.有一个很好的序列,随着时间的推移平稳地增加和减少.但是差异很小,非常糟糕.请参考下图:

绘制序列

你也可以在这里找到数据:

2.0789 2.09604 2.11472 2.13414 2.15609 2.17776 2.2021 2.22722 2.25019 2.27304 2.29724 2.31991 2.34285 2.36569 2.38682 2.40634 2.42068 2.43947 2.45099 2.46564 2.48385 2.49747 2.49031 2.51458 2.5149 2.52632 2.54689 2.56077 2.57821 2.57877 2.59104 2.57625 2.55987 2.5694 2.56244 2.56599 2.54696 2.52479 2.50345 2.48306 2.50934 2.4512 2.43586 2.40664 2.38721 2.3816 2.36415 2.33408 2.31225 2.28801 2.26583 2.24054 2.2135 2.19678 2.16366 2.13945 2.11102 2.08389 2.05533 2.02899 2.00373 1.9752 1.94862 1.91982 1.89125 1.86307 1.83539 1.80641 1.77946 1.75333 1.72765 1.70417 1.68106 1.65971 1.64032 1.62386 1.6034 1.5829 …

c++ image-processing user-interaction curvesmoothing

5
推荐指数
0
解决办法
558
查看次数

使用迭代器删除元素,而不知道向量

我有一个情况.我已经使用模板化函数完成了我的任务之一.对于这个函数,我通过引用传递迭代器.现在,我必须从向量中删除一些元素.如何仅使用迭代器来完成此操作?Pl找到相应的代码:

template <class BidirectionalIterator, class Iterator> bool

SomeFunc( BidirectionalIterator& first, BidirectionalIterator& last, Iterator anotherVecBegin )
{
    while((first+1) != last)
    {
        if(some_condition)
            // delete (first); HOW?
        else if(some_other_condition)
            // delete (first + 1); HOW?
    }

    // add something to another vector using anotherVecBegin

    return true;
}
Run Code Online (Sandbox Code Playgroud)

有许多已经问过的问题,但它们都有一个上下文的向量.所以myVec.erase(*first)很容易..

我也知道它不是一个非常好的方式,我通过引用传递迭代器.但我遵循简单的规则:在预期某些事情发生变化时使用引用或避免重复复制.我的方案符合第一个条件.

那么如何删除?

c++ templates iterator vector c++11

5
推荐指数
1
解决办法
610
查看次数

gnuplot - 绘制不同颜色的不同块

我有一个这样的数据 file.dat

2 2
5 5
7 3

100 102
130 80
116 134

-40 -100
-50 -60
-61 -58
Run Code Online (Sandbox Code Playgroud)

我想用不同的颜色绘制每个块,

没有特定颜色的限制,只是一些视觉上不同的颜色.

我尝试过linetype像这样:

for [IDX=0:2] 'file.dat' i IDX u 1:2 with linespoints linetype IDX
Run Code Online (Sandbox Code Playgroud)

它绘制了所有具有不同颜色的块,显然只有最后一块是可见的.

那么这样做的正确方法是什么?

plot gnuplot

5
推荐指数
1
解决办法
1759
查看次数

Theano - Keras - 没有名为`pool`的模块

bleeding edge theano按以下顺序安装了一个和以下的软件包:

gfortran:

sudo apt-get install gfortran 
Run Code Online (Sandbox Code Playgroud)

OpenBLAS:

git clone https://github.com/xianyi/OpenBLAS  
cd OpenBLAS  
make FC=gfortran  
sudo make PREFIX=/usr/local install 
Run Code Online (Sandbox Code Playgroud)

Anaconda首先下载了Anaconda3-2.4.1-Linux-x86_64.sh,然后:

bash Anaconda3-2.4.1-Linux-x86_64.sh  
Run Code Online (Sandbox Code Playgroud)

然后,pydot(更新后):

conda update conda  
conda update anaconda  
conda install pydot 
Run Code Online (Sandbox Code Playgroud)

我克隆并安装了Theano:

git clone git://github.com/Theano/Theano.git
python setup.py develop
Run Code Online (Sandbox Code Playgroud)

我从那里搬到windowslinux并且非常高兴theano已经安装完毕.

我运行一个小脚本,以验证它确实正常工作.

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy as np
import time

vlen = 10*30*768 # assuming 30 cores and 768 threads per core
iters = 1000 …
Run Code Online (Sandbox Code Playgroud)

python machine-learning theano deep-learning keras

5
推荐指数
0
解决办法
3054
查看次数