IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Explorar el Código

Better way to compute DecagonLayer.

master
Stanislaw Adaszewski hace 4 años
padre
commit
d56bbf745f
Se han modificado 3 ficheros con 769 adiciones y 29 borrados
  1. +729
    -6
      docs/decagon-diagram.svg
  2. +2
    -2
      src/decagon_pytorch/data.py
  3. +38
    -21
      src/decagon_pytorch/layer.py

+ 729
- 6
docs/decagon-diagram.svg Ver fichero

@@ -17,7 +17,227 @@
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="decagon-diagram.svg">
<defs
id="defs2" />
id="defs2">
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="marker3123"
style="overflow:visible;"
inkscape:isstock="true">
<path
id="path3121"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="marker3029"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lstart">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path3027" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible;"
id="marker2929"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lend">
<path
transform="scale(0.8) rotate(180) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path2927" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="marker2847"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path2845"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="marker2759"
style="overflow:visible;"
inkscape:isstock="true">
<path
id="path2757"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="marker2689"
style="overflow:visible"
inkscape:isstock="true">
<path
id="path2687"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="marker2559"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:collect="always">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path2557" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="marker2501"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:collect="always">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path2499" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lstart"
style="overflow:visible"
inkscape:isstock="true"
inkscape:collect="always">
<path
id="path1417"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="marker2393"
style="overflow:visible;"
inkscape:isstock="true"
inkscape:collect="always">
<path
id="path2391"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible;"
id="marker2347"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lend"
inkscape:collect="always">
<path
transform="scale(0.8) rotate(180) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path2345" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible;"
id="marker2307"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lend"
inkscape:collect="always">
<path
transform="scale(0.8) rotate(180) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path2305" />
</marker>
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="marker2009"
style="overflow:visible;"
inkscape:isstock="true"
inkscape:collect="always">
<path
id="path2007"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible;"
id="marker1703"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lend"
inkscape:collect="always">
<path
transform="scale(0.8) rotate(180) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path1701" />
</marker>
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lend"
style="overflow:visible;"
inkscape:isstock="true"
inkscape:collect="always">
<path
id="path1420"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
@@ -26,8 +246,8 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="375.00135"
inkscape:cy="277.05997"
inkscape:cx="75.316161"
inkscape:cy="262.38784"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
@@ -37,9 +257,9 @@
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1381"
inkscape:window-height="1008"
inkscape:window-x="-7"
inkscape:window-width="1367"
inkscape:window-height="1080"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0" />
<metadata
@@ -1108,5 +1328,508 @@
id="path1319"
d="m 389.91541,60.466463 c 12.56167,0 18.70886,6.147199 18.70886,6.147199"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
x="-11.760755"
y="200.34787"
id="text1323"
transform="scale(0.85401742,1.1709363)"><tspan
sodipodi:role="line"
id="tspan1321"
x="-11.760755"
y="200.34787"
style="stroke-width:0.86446381">[</tspan></text>
<text
transform="scale(-0.85401742,1.1709363)"
id="text1327"
y="200.57613"
x="-46.399681"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
xml:space="preserve"><tspan
style="stroke-width:0.86446381"
y="200.57613"
x="-46.399681"
id="tspan1325"
sodipodi:role="line">[</tspan></text>
<flowRoot
xml:space="preserve"
id="flowRoot1329"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
transform="matrix(0.26458333,0,0,0.26458333,32.257682,37.027326)"><flowRegion
id="flowRegion1331"><rect
id="rect1333"
width="213.14218"
height="148.49243"
x="-117.1777"
y="631.53986" /></flowRegion><flowPara
id="flowPara1335">0 0 1</flowPara><flowPara
id="flowPara1337">1 0 0</flowPara><flowPara
id="flowPara1339">0 1 0</flowPara></flowRoot> <text
transform="scale(0.85401742,1.1709363)"
id="text1343"
y="200.57613"
x="43.945343"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
xml:space="preserve"><tspan
style="stroke-width:0.86446381"
y="200.57613"
x="43.945343"
id="tspan1341"
sodipodi:role="line">[</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
x="-102.10577"
y="200.80438"
id="text1347"
transform="scale(-0.85401742,1.1709363)"><tspan
sodipodi:role="line"
id="tspan1345"
x="-102.10577"
y="200.80438"
style="stroke-width:0.86446381">[</tspan></text>
<flowRoot
transform="matrix(0.26458333,0,0,0.26458333,79.831658,37.294596)"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
id="flowRoot1359"
xml:space="preserve"><flowRegion
id="flowRegion1351"><rect
y="631.53986"
x="-117.1777"
height="148.49243"
width="213.14218"
id="rect1349" /></flowRegion><flowPara
id="flowPara1353">0 0 1</flowPara><flowPara
id="flowPara1355">1 0 0</flowPara><flowPara
id="flowPara1357">0 1 0</flowPara></flowRoot> <text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:20.50874329px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.51271856"
x="8.0774174"
y="199.04413"
id="text1363"><tspan
sodipodi:role="line"
id="tspan1361"
x="8.0774174"
y="199.04413"
style="stroke-width:0.51271856">A</tspan></text>
<text
id="text1367"
y="199.57867"
x="58.056816"
style="font-style:normal;font-weight:normal;font-size:20.50874329px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.51271856"
xml:space="preserve"><tspan
style="stroke-width:0.51271856"
y="199.57867"
x="58.056816"
id="tspan1365"
sodipodi:role="line">x</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
x="118.42877"
y="200.11961"
id="text1371"
transform="scale(0.85401742,1.1709363)"><tspan
sodipodi:role="line"
id="tspan1369"
x="118.42877"
y="200.11961"
style="stroke-width:0.86446381">[</tspan></text>
<text
transform="scale(-0.85401742,1.1709363)"
id="text1375"
y="200.34787"
x="-176.58919"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
xml:space="preserve"><tspan
style="stroke-width:0.86446381"
y="200.34787"
x="-176.58919"
id="tspan1373"
sodipodi:role="line">[</tspan></text>
<flowRoot
xml:space="preserve"
id="flowRoot1387"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
transform="matrix(0.26458333,0,0,0.26458333,143.4418,36.760057)"><flowRegion
id="flowRegion1379"><rect
id="rect1377"
width="213.14218"
height="148.49243"
x="-117.1777"
y="631.53986" /></flowRegion><flowPara
id="flowPara1381">0 0 1</flowPara><flowPara
id="flowPara1383">1 0 0</flowPara><flowPara
id="flowPara1385">0 1 0</flowPara></flowRoot> <text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:20.50874329px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.51271856"
x="121.66697"
y="199.04413"
id="text1391"><tspan
sodipodi:role="line"
id="tspan1389"
x="121.66697"
y="199.04413"
style="stroke-width:0.51271856">x'</tspan></text>
<text
id="text1395"
y="229.78012"
x="85.852852"
style="font-style:normal;font-weight:normal;font-size:20.50874329px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.51271856"
xml:space="preserve"><tspan
style="stroke-width:0.51271856"
y="229.78012"
x="85.852852"
id="tspan1393"
sodipodi:role="line">=</tspan></text>
<circle
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path1397"
cx="42.814827"
cy="282.56586"
r="7.6171813" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
x="39.719658"
y="285.88281"
id="text1401"><tspan
sodipodi:role="line"
id="tspan1399"
x="39.719658"
y="285.88281"
style="stroke-width:0.23702957">1</tspan></text>
<circle
r="7.6171813"
cy="307.95645"
cx="43.082096"
id="circle1403"
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
id="text1407"
y="311.27341"
x="39.986927"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
xml:space="preserve"><tspan
style="stroke-width:0.23702957"
y="311.27341"
x="39.986927"
id="tspan1405"
sodipodi:role="line">2</tspan></text>
<circle
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle1409"
cx="66.869087"
cy="294.32571"
r="7.6171813" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
x="63.773914"
y="297.64267"
id="text1413"><tspan
sodipodi:role="line"
id="tspan1411"
x="63.773914"
y="297.64267"
style="stroke-width:0.23702957">3</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
d="M 59.519173,289.91577 49.89747,285.10492"
id="path1415"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path1699"
d="m 42.681193,289.91577 0.267269,10.15624"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker1703)"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker2009)"
d="m 50.432009,305.15013 12.294398,-4.54358"
id="path2005"
inkscape:connector-curvature="0" />
<text
transform="scale(0.85401742,1.1709363)"
id="text2145"
y="263.34564"
x="-27.408535"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
xml:space="preserve"><tspan
style="stroke-width:0.86446381"
y="263.34564"
x="-27.408535"
id="tspan2143"
sodipodi:role="line">[</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
x="-30.751902"
y="263.57391"
id="text2149"
transform="scale(-0.85401742,1.1709363)"><tspan
sodipodi:role="line"
id="tspan2147"
x="-30.751902"
y="263.57391"
style="stroke-width:0.86446381">[</tspan></text>
<flowRoot
transform="matrix(0.26458333,0,0,0.26458333,18.894206,110.79372)"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
id="flowRoot2161"
xml:space="preserve"><flowRegion
id="flowRegion2153"><rect
y="631.53986"
x="-117.1777"
height="148.49243"
width="213.14218"
id="rect2151" /></flowRegion><flowPara
id="flowPara2155">0 0 1</flowPara><flowPara
id="flowPara2157">1 0 0</flowPara><flowPara
id="flowPara2159">0 1 0</flowPara></flowRoot> <text
id="text2165"
y="272.81052"
x="-5.2860589"
style="font-style:normal;font-weight:normal;font-size:20.50874329px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.51271856"
xml:space="preserve"><tspan
style="stroke-width:0.51271856"
y="272.81052"
x="-5.2860589"
id="tspan2163"
sodipodi:role="line">A</tspan></text>
<circle
r="7.6171813"
cy="353.39227"
cx="41.211208"
id="circle2257"
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
id="text2261"
y="356.70923"
x="38.116039"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
xml:space="preserve"><tspan
style="stroke-width:0.23702957"
y="356.70923"
x="38.116039"
id="tspan2259"
sodipodi:role="line">1</tspan></text>
<circle
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle2263"
cx="41.478477"
cy="378.78287"
r="7.6171813" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
x="38.383308"
y="382.09982"
id="text2267"><tspan
sodipodi:role="line"
id="tspan2265"
x="38.383308"
y="382.09982"
style="stroke-width:0.23702957">2</tspan></text>
<circle
r="7.6171813"
cy="365.15213"
cx="65.265472"
id="circle2269"
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
id="text2273"
y="368.46909"
x="62.170296"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
xml:space="preserve"><tspan
style="stroke-width:0.23702957"
y="368.46909"
x="62.170296"
id="tspan2271"
sodipodi:role="line">3</tspan></text>
<path
inkscape:connector-curvature="0"
id="path2275"
d="m 57.915556,360.74219 -9.621703,-4.81085"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker2307);marker-start:url(#marker2501)" />
<path
sodipodi:nodetypes="cc"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker2393);marker-start:url(#marker2559)"
d="m 41.077576,360.74219 0.267269,10.15624"
id="path2277"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path2279"
d="M 48.828392,375.97655 61.12279,371.43297"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#marker2347);marker-start:url(#Arrow1Lstart)"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
x="-29.286268"
y="323.83264"
id="text2283"
transform="scale(0.85401742,1.1709363)"><tspan
sodipodi:role="line"
id="tspan2281"
x="-29.286268"
y="323.83264"
style="stroke-width:0.86446381">[</tspan></text>
<text
transform="scale(-0.85401742,1.1709363)"
id="text2287"
y="324.06091"
x="-28.874168"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
xml:space="preserve"><tspan
style="stroke-width:0.86446381"
y="324.06091"
x="-28.874168"
id="tspan2285"
sodipodi:role="line">[</tspan></text>
<flowRoot
xml:space="preserve"
id="flowRoot2299"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
transform="matrix(0.26458333,0,0,0.26458333,17.290589,181.62014)"><flowRegion
id="flowRegion2291"><rect
id="rect2289"
width="213.14218"
height="148.49243"
x="-117.1777"
y="631.53986" /></flowRegion><flowPara
id="flowPara2293">0 1 1</flowPara><flowPara
id="flowPara2295">1 0 1</flowPara><flowPara
id="flowPara2297">1 1 0</flowPara></flowRoot> <text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:20.50874329px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.51271856"
x="-11.967797"
y="342.83511"
id="text2303"><tspan
sodipodi:role="line"
id="tspan2301"
x="-11.967797"
y="342.83511"
style="stroke-width:0.51271856">A2</tspan></text>
<circle
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle2639"
cx="41.478477"
cy="428.22775"
r="7.6171813" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
x="38.383308"
y="431.54471"
id="text2643"><tspan
sodipodi:role="line"
id="tspan2641"
x="38.383308"
y="431.54471"
style="stroke-width:0.23702957">1</tspan></text>
<circle
r="7.6171813"
cy="453.61835"
cx="41.745747"
id="circle2645"
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
id="text2649"
y="456.9353"
x="38.650578"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
xml:space="preserve"><tspan
style="stroke-width:0.23702957"
y="456.9353"
x="38.650578"
id="tspan2647"
sodipodi:role="line">2</tspan></text>
<circle
style="opacity:1;vector-effect:none;fill:#b9b9b9;fill-opacity:1;stroke:#000000;stroke-width:0.66500002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="circle2651"
cx="65.532745"
cy="439.98761"
r="7.6171813" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:9.48118305px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.23702957"
x="62.437565"
y="443.30457"
id="text2655"><tspan
sodipodi:role="line"
id="tspan2653"
x="62.437565"
y="443.30457"
style="stroke-width:0.23702957">3</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#marker2689);marker-end:"
d="M 58.182826,435.57765 48.561123,430.7668"
id="path2657"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path2659"
d="m 41.344846,435.57765 0.267269,10.15624"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#marker2847);marker-end:"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#marker3029);marker-end:"
d="M 49.095662,450.81201 61.39006,446.26843"
id="path2661"
inkscape:connector-curvature="0" />
<text
transform="scale(0.85401742,1.1709363)"
id="text2665"
y="387.74344"
x="-28.973312"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
xml:space="preserve"><tspan
style="stroke-width:0.86446381"
y="387.74344"
x="-28.973312"
id="tspan2663"
sodipodi:role="line">[</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:34.57855606px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.86446381"
x="-29.187124"
y="387.97171"
id="text2669"
transform="scale(-0.85401742,1.1709363)"><tspan
sodipodi:role="line"
id="tspan2667"
x="-29.187124"
y="387.97171"
style="stroke-width:0.86446381">[</tspan></text>
<flowRoot
transform="matrix(0.26458333,0,0,0.26458333,17.557859,256.4556)"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none"
id="flowRoot2681"
xml:space="preserve"><flowRegion
id="flowRegion2673"><rect
y="631.53986"
x="-117.1777"
height="148.49243"
width="213.14218"
id="rect2671" /></flowRegion><flowPara
id="flowPara2675">0 1 0</flowPara><flowPara
id="flowPara2677">0 0 1</flowPara><flowPara
id="flowPara2679">1 0 0</flowPara></flowRoot> <text
id="text2685"
y="418.47241"
x="-6.6224065"
style="font-style:normal;font-weight:normal;font-size:20.50874329px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.51271856"
xml:space="preserve"><tspan
style="stroke-width:0.51271856"
y="418.47241"
x="-6.6224065"
id="tspan2683"
sodipodi:role="line">A'</tspan></text>
</g>
</svg>

+ 2
- 2
src/decagon_pytorch/data.py Ver fichero

@@ -19,13 +19,13 @@ class RelationType(object):
def get_adjacency_matrix(node_type_row, node_type_column):
if self.node_type_row == node_type_row and \
self.node_type_column = node_type_column:
self.node_type_column == node_type_column:
return self.adjacency_matrix
elif self.node_type_row == node_type_column and \
self.node_type_column == node_type_row:
return self.adjacency_matrix.transpose(0, 1)
else:
raise ValueError('Specified row/column types do not correspond to this relation')


+ 38
- 21
src/decagon_pytorch/layer.py Ver fichero

@@ -21,11 +21,12 @@
import torch
from .convolve import SparseMultiDGCA
from .convolve import SparseDropoutGraphConvActivation
from .data import Data
from typing import List, \
Union, \
Callable
from collections import defaultdict
class Layer(torch.nn.Module):
@@ -89,30 +90,46 @@ class DecagonLayer(Layer):
def build(self):
self.convolutions = {}
for key in self.data.relation_types.keys():
for (node_type_row, node_type_column) in self.data.relation_types.keys():
adjacency_matrices = \
self.data.get_adjacency_matrices(*key)
self.convolutions[key] = SparseMultiDGCA(self.input_dim,
self.data.get_adjacency_matrices(node_type_row, node_type_column)
self.convolutions[node_type_row, node_type_column] = SparseMultiDGCA(self.input_dim,
self.output_dim, adjacency_matrices,
self.keep_prob, self.rel_activation)
# for node_type_row, node_type_col in enumerate(self.data.node_
# if rt.node_type_row == i or rt.node_type_col == i:
def __call__(self, prev_layer_repr):
new_layer_repr = []
for i, nt in enumerate(self.data.node_types):
new_repr = []
for key in self.data.relation_types.keys():
nt_row, nt_col = key
if nt_row != i and nt_col != i:
continue
if nt_row == i:
x = prev_layer_repr[nt_col]
else:
x = prev_layer_repr[nt_row]
conv = self.convolutions[key]
new_repr.append(conv(x))
new_repr = sum(new_repr)
new_layer_repr.append(new_repr)
return new_layer_repr
def __call__(self):
prev_layer_repr = self.previous_layer()
next_layer_repr = defaultdict(list)
for (nt_row, nt_col), rel in self.data.relation_types.items():
conv = SparseDropoutGraphConvActivation(self.input_dim[nt_col],
self.output_dim[nt_row], rel.adjacency_matrix,
self.keep_prob, self.rel_activation)
next_layer_repr[nt_row].append(conv)
conv = SparseDropoutGraphConvActivation(self.input_dim[nt_row],
self.output_dim[nt_col], rel.adjacency_matrix.transpose(0, 1),
self.keep_prob, self.rel_activation)
next_layer_repr[nt_col].append(conv)
next_layer_repr = list(map(sum, next_layer_repr))
return next_layer_repr
#for i, nt in enumerate(self.data.node_types):
# new_repr = []
# for nt_row, nt_col in self.data.relation_types.keys():
# if nt_row != i and nt_col != i:
# continue
# if nt_row == i:
# x = prev_layer_repr[nt_col]
# else:
# x = prev_layer_repr[nt_row]
# conv = self.convolutions[key]
# new_repr.append(conv(x))
# new_repr = sum(new_repr)
# new_layer_repr.append(new_repr)
# return new_layer_repr

Cargando…
Cancelar
Guardar