<div style="font:14px/1.5 'Lucida Grande', '微软雅黑';color:#333;"><p style="font:14px/1.5 'Lucida Grande';margin:0;">Hi,</p><p style="font:14px/1.5 'Lucida Grande';margin:0;"><br></p><p style="font:14px/1.5 'Lucida Grande';margin:0;"><span class="Apple-tab-span" style="white-space:pre">                </span><span style="line-height: 1.5;">I'm not sure about the number of connection. Maybe it is a better idea to write</span></p><div class="" style="font-family: 'Lucida Grande';"><span class="Apple-tab-span" style="white-space:pre">                </span>a new layer type and a new connection. Which will reduce the problem to 5 layer.</div><div class="" style="font-family: 'Lucida Grande';"><br></div><div class="" style="font-family: 'Lucida Grande';">The structure of LeNet5:</div><div class="" style="font-family: 'Lucida Grande';"><img src="cid:F3748ED1211CE7523F5E0A2D6AC6204B" modifysize="100%" style="width: 748px; height: 224px;"></div><div class="" style="font-family: 'Lucida Grande';">With an input layer, 6 convolutional kernel is used to generate 6 feature maps(C1).</div><div class="" style="font-family: 'Lucida Grande';">I modled each feature map as a layer.</div><div class="" style="font-family: 'Lucida Grande';">then apply pooling on each feature maps in C1&nbsp;</div><div class="" style="font-family: 'Lucida Grande';">and get 6 feature maps in S2 (denoting them as S2_1, S2_2, …, S2_6)</div><div class="" style="font-family: 'Lucida Grande';">And C3 has 16 feature maps (denoting them as C3_1, C3_2, …., C3_16).</div><div class="" style="font-family: 'Lucida Grande';">There are many kinds of connection strategies between S2 and C3.</div><div class="" style="font-family: 'Lucida Grande';">Maybe C3_1 is connected with S2_2 only, but C3_1 may also be connected with all 6 feature maps in S2.</div><div class="" style="font-family: 'Lucida Grande';">I learn that an implementation in theano use full connections.</div><div class="" style="font-family: 'Lucida Grande';">I just want to imitate it so 6 * 16 = 96 connections is need.</div><div class="" style="font-family: 'Lucida Grande';">I can’t design one ConnectionType to include all these connections,&nbsp;</div><div class="" style="font-family: 'Lucida Grande';">as the number of connections and the structure of connections are uncertain.</div><div class="" style="font-family: 'Lucida Grande';"><br></div><div class="" style="font-family: 'Lucida Grande';">Best</div><div class="" style="font-family: 'Lucida Grande';">Regards</div><br><div><div style="font: 14px/1.5 'Lucida Grande';"><span style="font-family: 'lucida Grande', Verdana; font-size: 12px; line-height: 18px;">Shangtong Zhang,</span><div style="font-family: 'lucida Grande', Verdana; font-size: 12px; line-height: 18px;">Third Year Undergraduate,</div><div style="font-family: 'lucida Grande', Verdana; font-size: 12px; line-height: 18px;">School of Computer Science,</div><div style="font-family: 'lucida Grande', Verdana; font-size: 12px; line-height: 18px;">Fudan University, China.</div></div></div><span style="font: 14px/1.5 'Lucida Grande';color:#333;"><br></span><div class="foxmail_blockquote_fromhere_element" style="font: 12px/1.5 'Lucida Grande';padding:2px 0 2px 0;"><span style="color:#333;text-decoration:line-through;white-space:pre-wrap;">                            </span>&nbsp;原始邮件&nbsp;<span style="color:#333;text-decoration:line-through;white-space:pre-wrap;">                            </span></div><div style="font: 12px/1.5 'Lucida Grande';background:#efefef;color:#666666;padding:8px;"><div><b style="color:#999;">发件人:</b>&nbsp;Marcus Edel&lt;marcus.edel@fu-berlin.de&gt;</div><div><b style="color:#999;">收件人:</b>&nbsp;Ryan Curtin&lt;ryan@ratml.org&gt;</div><div><b style="color:#999;">抄送:</b>&nbsp;Shangtong Zhang&lt;zhangshangtong.cpp@qq.com&gt;; mlpack&lt;mlpack@cc.gatech.edu&gt;</div><div><b style="color:#999;">发送时间:</b>&nbsp;2015年2月10日(周二) 05:58</div><div><b style="color:#999;">主题:</b>&nbsp;Re: [mlpack] disadvantages of using tuple as framework for neural network</div></div><br><div class="mail_quote_5085586832734985B63EF33843A79423" style="font: 14px/1.5 'Lucida Grande';color:#333;"><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hello,</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><span class="" style="float: none; display: inline !important;">Using a base class for all ConnectionType classes would mean virtual</span><br class=""><span class="" style="float: none; display: inline !important;">functions, which in this context would incur non-negligible slowdown</span><br class=""><span class="" style="float: none; display: inline !important;">(since the ConnectionType's functions will be used so much).</span></blockquote></div><div class=""><br class=""></div><div class="">This is absolutely right, using inheritance would results in a measurable</div><div class="">slowdown, which is non-negligible. I couldn't think of another solution as using</div><div class="">tuples in combination with variadic templates to support different layers. Which</div><div class="">doesn't mean there isn't a better solution.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><blockquote type="cite" class="">But it seems I can't generate it automatically<br class="">or I need some very complicate c++ technique to do this.<br class=""><a href="http://stackoverflow.com/questions/28410697/c-convert-vector-to-tuple" class="">http://stackoverflow.com/questions/28410697/c-convert-vector-to-tuple</a></blockquote></blockquote><br class=""></div><div class="">I think Barry's solution is quite neat, I've done something similar in the RNN</div><div class="">and FFN class. Originally there was the plan to write a 'BuildNetwork' function</div><div class="">which simply creates a network with k units and n layer (layer with the same</div><div class="">type), but I couldn't find the time to write such a function. However, the problem</div><div class="">with the idea is that often we need a different layer type between two layer. Maybe</div><div class="">it makes more sense to write a function which generates a block of layers, like</div><div class="">you asked at stackoverflo. What do you think?</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><blockquote type="cite" class="">This means there are 6 * 16 = 96 connections,<br class="">then I need to instantiates 96 class of ConnectionType and store them in a tuple.<br class="">so I need to get a tuple like c1, c2, c3, ………, c96, it’s too large that I can’t write it manually.</blockquote></blockquote><br class=""></div><div class=""><div class="">I'm not sure about the number of connection. Maybe it is a better idea to write</div><div class="">a new layer type and a new connection. Which will reduce the problem to 5 layer.</div></div><div class=""><br class=""></div><div class="">Thank you for according time and effort into the code,</div><div class=""><br class=""></div><div class="">Marcus</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 09 Feb 2015, at 17:36, Ryan Curtin &lt;<a href="mailto:ryan@ratml.org" class="">ryan@ratml.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Mon, Feb 09, 2015 at 10:17:39PM +0800, Shangtong Zhang wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Hi,<br class=""><br class=""><br class="">I implement cnn based on current framework of NN.<br class="">I meet some problem when I try to test my cnn on mnist dataset.<br class="">To do classification on mnist dataset, I try to realize LeNet5,<br class="">but LeNet5 has so many connections.<br class="">In one layer, there are 6 feature maps, and in next layer there are 16 feature maps.<br class="">And an implementation in theano connects these two layers use full connection.<br class="">This means there are 6 * 16 = 96 connections,<br class="">then I need to instantiates 96 class of ConnectionType and store them in a tuple.<br class="">so I need to get a tuple like c1, c2, c3, ………, c96, it’s too large that I can’t write it manually.<br class="">But it seems I can't generate it automatically<br class="">or I need some very complicate c++ technique to do this.<br class=""><a href="http://stackoverflow.com/questions/28410697/c-convert-vector-to-tuple" class="">http://stackoverflow.com/questions/28410697/c-convert-vector-to-tuple</a><br class=""><br class="">So I think tuple isn't appropriate for this work.<br class="">I suggest that we use vector to replace tuple and have a base class for all ConnectionType class.<br class="">In this way, ConnectionTraits may also be not used.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Using a base class for all ConnectionType classes would mean virtual</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">functions, which in this context would incur non-negligible slowdown</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">(since the ConnectionType's functions will be used so much).</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Although I agree that making a std::tuple&lt;&gt; with 96 objects in it is</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">unwieldy, we should be careful to consider the drawbacks of inheritance</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">in a library that focuses on speed.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I've barely looked at the code in methods/ann/, so I certainly don't</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">have any better ideas, but I at least wanted to point out this</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">perspective.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Ryan Curtin &nbsp;&nbsp;&nbsp;| "You got to stick with your principles."</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:ryan@ratml.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">ryan@ratml.org</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>| &nbsp;&nbsp;- Harry Waters</span></div></blockquote></div><br class=""></div>
</div></div>