Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/dpv/AutoencoderDPV.m4

raw
1 .PS
2 # Masked_Autoencoder.m4
3 gen_init
4 NeedDpicTools
5 svg_font(sans-serif,12bp__,textoffset)
6
7 circlerad = 0.2
8 circlesep = 0.5
9 rowsep = 0.9
10 arrowht = arrowht*0.8
11 arrowwid = arrowwid*1.4
12 linethick = 1
13
14 define plan {
15 m = 0
16 for i=1 to 4 do {
17 for j=1 to ncircles[i] do {
18 exec sprintf("C[i,j]: circle thick 1.6 \"%g\" at Here",m+j)
19 if i>1 then {
20 if "$1"=="" then {
21 for k=1 to ncircles[i-1] do { arrow from C[i,j] to C[i-1,k] chop } }
22 }
23 if j!=ncircles[i] then { move right_ circlesep from C[i,j] }
24 }
25 m += ncircles[i]
26 case(i,
27 move to C[1,1]+(-circlesep/2,-rowsep),
28 move to C[2,1]+(0,-rowsep),
29 move to C[3,1]+(circlesep/2,-rowsep), )
30 }
31 }
32 gridsiz = 0.78/4
33 define grid { [ SW: 0,0
34 for i=1 to $1 do {
35 move to (0,(0.5-i)*gridsiz)
36 exec sprintf("fv = $%g",2+i)
37 for j=1 to $2 do { fl = 1-(int(fv / 2^(j-1)) % 2)
38 box wid gridsiz ht gridsiz outlined "gray" shaded rgbstring(fl,fl,fl) }
39 } ]}
40
41 define cxt {
42 m = 1
43 for i=2 to 4 do {
44 for j=1 to ncircles[i] do {
45 exec sprintf("narrows = $%g",m)
46 for k=1 to narrows do {
47 exec sprintf("cnum = $%g",m+k)
48 exec sprintf("arrow from C[i,j] to C[i-1,cnum] $%g chop", $+)
49 }
50 m += narrows+1
51 } } }
52
53 B: box invis ht 8 wid 8
54 [
55 array(ncircles,3,4,4,3)
56 plan()
57 svg_font(Times,12bp__,textoffset)
58 for j=1 to 3 do {
59 sprintf("svg_it(x)`'svg_sub(%g,60%)",j) at C[1,j].n+(0,2bp__) above
60 "svg_circ" at last ""+(-1bp__,1bp__)
61 sprintf("svg_it(x)`'svg_sub(%g,60%)",j) at C[4,j].s+(0,-2bp__) below
62 }
63
64 "V" at 0.5 between C[2,1].w and C[1,1].w
65 "W`'svg_sup(2)" at 0.5 between C[3,1].w and C[2,1].w
66 "W`'svg_sup(1)" at 0.5 between C[3,1].w and C[4,1].w
67
68 GV: grid(3,4,0,15,6) with .w at C[2,4]+(circlerad*2,rowsep/2)
69 "=M`'svg_sup(V)" at GV.e ljust
70 G2: grid(4,4,13,0,0,13) with .w at (GV.w,C[3,4]+(circlerad*2,rowsep/2))
71 "=M`'svg_sup(V`'svg_sup(2))" at G2.e ljust
72 G1: grid(4,3,1,5,1,1) with .w at (GV.w,C[4,3]+(circlerad*2,rowsep/2))
73 "=M`'svg_sup(V`'svg_sup(1))" at G1.e ljust
74 command "</g>"
75
76 move to (GV.x+3*circlesep,C[1,1].y)
77 plan(3,1,2,1,2,2,1,2,1,2,2,3,1,2)
78 for i=2 to 4 do {
79 cxt(2,1,3,0,0,2,1,3, 0,4,1,2,3,4,0,0, 0,4,1,2,3,4,0, \
80 outlined rgbstring(0.5,0.5,0.5) shaded rgbstring(0.5,0.5,0.5) )
81 cxt(0,1,1,1,1,0, 2,2,3,0,2,2,3,2,2,3, 0,0,3,1,3,4,)
82 }
83 svg_font(Times,12bp__,textoffset)
84 for j=1 to 3 do { sprintf("svg_it(x)`'svg_sub(%g,60%)",j) \
85 at C[4,j].s+(0,-2bp__) below }
86 arrow dotted from C[1,2].n up circlesep/2
87 "svg_it(p(x`'svg_sub(2)))" at Here+(0,2bp__) above
88 "svg_it(p(x`'svg_sub(3)|x`'svg_sub(2)))" at (C[1,3]+(circlesep/2,0),last "")
89 arrow dotted from C[1,3] to last "".s chop circlerad chop textoffset
90 "svg_it(p(x`'svg_sub(1)|x`'svg_sub(2),x`'svg_sub(3)))" \
91 at (C[1,1]+(-circlesep/2,0),last "")
92 arrow dotted from C[1,1] to last "".s chop circlerad chop textoffset
93 command "</g>"
94
95 ] at B
96 command "</g>"
97 .PE