There seems to be a mistake with the way layers are computed in the updated Net.scala code
DanielTakeshi opened this issue · 1 comments
OS: Linux
BIDMach version: 3275bef
(BIDMat is also up to date)
The Net.scala class was last updated in commit ebe1a17 with a change to the way layers were computed. However, I think there is an error in which the layers are computed.
The code for dnodes2 says (the other dnodes3 and dnodes4 are similar):
/**
* Build a net with a stack of nodes. node(0) is an input node, node(n-1) is a GLM node.
* Intermediate nodes are Linear followed by nonlinear, starting and ending with Linear.
* First Linear node width is given as an argument, then it tapers off by taper.
*/
def dnodes2(nslabs:Int, width:Int, taper:Float, ntargs:Int, opts:Opts, nonlin:Int = 1):NodeSet = {
val widths = (width * int(taper ^ row(0 -> (nslabs-1)))) \ ntargs;
powerNet(widths, opts, 0, nonlin);
}
But the widths
variable is not computed correctly. The int
command there will turn the inside into 1 for the first component and zero for the others. The fix is to move the 'int' part outside the parentheses. For instance, here's some code I used in the BIDMach command line with sample values for the variables here. I then compute widths
using the way the code has it written, which returns mostly zeros, and then I have widths
computed with my recommended changes, and the output makes sense, especially since the PowerNet
method says that the widths
should specify output dimensions, i.e., the number of nodes in a layer.
scala> val nslabs = 6; val width = 100; val taper = 0.5f; val ntargs = 10;
nslabs: Int = 6
width: Int = 100
taper: Float = 0.5
ntargs: Int = 10
scala> val widths = (width * int(taper ^ row(0 -> (nslabs-1)))) \ ntargs;
widths: BIDMat.IMat = 100,0,0,0,0,10
scala> val widths = int(width * (taper ^ row(0 -> (nslabs-1)))) \ ntargs;
widths: BIDMat.IMat = 100,50,25,12,6,10
21a3ebf did the trick, so I'm closing the issue.