CNN-Numpy
CNN-Numpy copied to clipboard
Questions
Hi, 请问可以解释一下为什么Conv2D中: weights_scale = math.sqrt(reduce(lambda x, y: x * y, shape) / self.output_channels), 这个weights_scale的作用和它为什么这么计算吗?
神经网络参数值初始化,这个部分我没有在专栏介绍.参考论文是何凯明的msra初始化方法、当然还有常用的xavier也可以、使用好的初始化能极大加速网络收敛.减少loss直接跑飞的情况.顺便回答一下为什么:论文的出发点是为了保证数据经过层的传输后标准差没有显著的变大或变小、否则bp的过程梯度会反方向变化、从而容易导致爆炸或消失
你看的应该是早期的版本了、在最新版本中、我专门实现了initializer的函数、可供选择、但一般这个问题放在比较后面、实际中网络跑飞了、这个是排查的优先级比较低、而且现在可选的不多、所以我没有专门介绍
谢谢回答。
请问新版本的代码在哪?这里你好像没有更新。
我看到的这个代码base_conv第22行
self.eta = np.zeros((shape[0], (shape[1] - ksize + 1) / self.stride, (shape[1] - ksize + 1) / self.stride,
这里第二个shape[1]是否应该是shape[2]呢?
tensor/Operator.py里面实现了Conv2D的类
欢迎参考我在知乎写的专栏、完整地介绍了所有的实现和代码细节、希望可以帮助到你 https://zhuanlan.zhihu.com/p/33773140?utm_medium=social&utm_source=wechat_timeline&from=timeline&isappinstalled=0
根据softmax的公式,按照我的理解,self.loss += np.log(np.sum(np.exp(prediction[i]))) - prediction[i] 应该是这样的啊,为什么您用的是prediction[i, label[i]]呢?
你理解的没错,但是prediction是一整个batch的结果,prediction[i,label[i]]计算的是第i个数据的Loss,所以这里有一个for循环。注意整个代码中流动的数据第一个维度都是batch
根据Adam的更新公式,self.data -= learning_rate_t * self.m_t / ((self.v_t ) **0.5+self.epsilon)吧,为什么你的代码里是self.data -= learning_rate_t * self.m_t / (self.v_t + self.epsilon) ** 0.5。我没有找到Adam中关于learning rate更新的公式,作者可以给个参考的文章链接吗?
xxxxx\CNN-Numpy-master\tensor\util.py", line 13, in initializer weights_scale = math.sqrt(reduce(lambda x, y: x * y, shape) / shape[-1]) NameError: name 'reduce' is not defined 请问这个reduce是哪里的函数啊
xxxxx\CNN-Numpy-master\tensor\util.py", line 13, in initializer weights_scale = math.sqrt(reduce(lambda x, y: x * y, shape) / shape[-1]) NameError: name 'reduce' is not defined 请问这个reduce是哪里的函数啊
from functools import reduce
https://www.runoob.com/python/python-func-reduce.html https://docs.python.org/zh-cn/3/library/functools.html
希望可以帮到你
------------------ Original message ------------------ From: "caoqi95"; Sendtime: Wednesday, Sep 4, 2019 3:32 PM To: "wuziheng/CNN-Numpy"; Cc: "Butterfly "[email protected]; "Comment"; Subject: Re: [wuziheng/CNN-Numpy] Questions (#1)
xxxxx\CNN-Numpy-master\tensor\util.py", line 13, in initializer weights_scale = math.sqrt(reduce(lambda x, y: x * y, shape) / shape[-1]) NameError: name 'reduce' is not defined 请问这个reduce是哪里的函数啊
from functools import reduce
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
lenet_layers.py 和 lenet_tensor.py 哪个更新啊?区别在哪里啊?我lenet_layers.py 可以跑了。
lenet_layers.py 和 lenet_tensor.py 哪个更新啊?区别在哪里啊?我lenet_layers.py 可以跑了。
请问你 lenet_layers.py 中 stride=2 的时候也能跑的通吗?