@@ -22,11 +22,17 @@ function LeNet() {
22
22
var betweenLayersDefault = 12 ;
23
23
24
24
var architecture = [ ] ;
25
+ var architecture2 = [ ] ;
25
26
var lenet = { } ;
26
27
var layer_offsets = [ ] ;
27
28
var largest_layer_width = 0 ;
28
29
var showLabels = true ;
29
30
31
+ var sqrtLength = false ;
32
+ var lengthScale = 100 ;
33
+
34
+ let lengthFn = ( length ) => sqrtLength ? ( Math . sqrt ( length ) * lengthScale / 10 ) : ( length * lengthScale / 100 ) ;
35
+
30
36
let textFn = ( layer ) => ( typeof ( layer ) === "object" ? layer [ 'numberOfSquares' ] + '@' + layer [ 'squareHeight' ] + 'x' + layer [ 'squareWidth' ] : "1x" + layer )
31
37
32
38
var rect , conv , link , poly , line , text , info ;
@@ -36,10 +42,14 @@ function LeNet() {
36
42
/////////////////////////////////////////////////////////////////////////////
37
43
38
44
function redraw ( { architecture_= architecture ,
39
- architecture2_= architecture2 } = { } ) {
45
+ architecture2_= architecture2 ,
46
+ sqrtLength_= sqrtLength ,
47
+ lengthScale_= lengthScale , } = { } ) {
40
48
41
49
architecture = architecture_ ;
42
50
architecture2 = architecture2_ ;
51
+ sqrtLength = sqrtLength_ ;
52
+ lengthScale = lengthScale_ ;
43
53
44
54
lenet . rects = architecture . map ( ( layer , layer_index ) => range ( layer [ 'numberOfSquares' ] ) . map ( rect_index => { return { 'id' :layer_index + '_' + rect_index , 'layer' :layer_index , 'rect_index' :rect_index , 'width' :layer [ 'squareWidth' ] , 'height' :layer [ 'squareHeight' ] } } ) ) ;
45
55
lenet . rects = flatten ( lenet . rects ) ;
@@ -50,7 +60,7 @@ function LeNet() {
50
60
lenet . conv_links = lenet . convs . map ( conv => { return [ Object . assign ( { 'id' :'link_' + conv [ 'layer' ] + '_0' , 'i' :0 } , conv ) , Object . assign ( { 'id' :'link_' + conv [ 'layer' ] + '_1' , 'i' :1 } , conv ) ] } ) ;
51
61
lenet . conv_links = flatten ( lenet . conv_links ) ;
52
62
53
- lenet . fc_layers = architecture2 . map ( ( size , fc_layer_index ) => { return { 'id' : 'fc_' + fc_layer_index , 'layer' :fc_layer_index + architecture . length , 'size' :size / Math . sqrt ( 2 ) } } ) ;
63
+ lenet . fc_layers = architecture2 . map ( ( size , fc_layer_index ) => { return { 'id' : 'fc_' + fc_layer_index , 'layer' :fc_layer_index + architecture . length , 'size' : lengthFn ( size ) } } ) ;
54
64
lenet . fc_links = lenet . fc_layers . map ( fc => { return [ Object . assign ( { 'id' :'link_' + fc [ 'layer' ] + '_0' , 'i' :0 , 'prevSize' :10 } , fc ) , Object . assign ( { 'id' :'link_' + fc [ 'layer' ] + '_1' , 'i' :1 , 'prevSize' :10 } , fc ) ] } ) ;
55
65
lenet . fc_links = flatten ( lenet . fc_links ) ;
56
66
0 commit comments