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!
Stanislaw Adaszewski 4 лет назад
Родитель
Сommit
13940671cc
4 измененных файлов: 630 добавлений и 0 удалений
  1. +438
    -0
      docs/nodes-involved.svg
  2. +131
    -0
      experiments/decagon_run_effcat/decagon_run_effcat.py
  3. +28
    -0
      src/icosagon/compile.py
  4. +33
    -0
      tests/icosagon/test_trainloop.py

+ 438
- 0
docs/nodes-involved.svg Просмотреть файл

@@ -0,0 +1,438 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg2092"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="nodes-involved.svg">
<defs
id="defs2086" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="586.4993"
inkscape:cy="581.57937"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-global="false"
showborder="false"
inkscape:window-width="2560"
inkscape:window-height="1361"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1" />
<metadata
id="metadata2089">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="path2637"
cx="31.805071"
cy="23.583265"
r="4.543582" />
<circle
r="4.543582"
cy="49.508408"
cx="57.997486"
id="circle2639"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2641"
cx="96.217033"
cy="14.496107"
r="4.543582" />
<circle
r="4.543582"
cy="63.673706"
cx="102.09696"
id="circle2643"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2645"
cx="30.735992"
cy="67.148193"
r="4.543582" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 35.279578,67.950009 62.273799,-4.00904"
id="path2647"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 98.889726,60.199199 62.006528,51.646569"
id="path2649"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 54.522983,46.835719 34.2105,26.790509"
id="path2651"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 60.135643,45.499369 93.009796,17.703339"
id="path2653"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
r="4.543582"
cy="42.024872"
cx="119.73676"
id="circle2655"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 62.541067,48.439339 52.117553,-5.07812"
id="path2657"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2659"
cx="147.80005"
cy="74.899017"
r="4.543582" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path2661"
d="m 122.94398,44.964839 21.9161,26.19241"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="path2637-7"
cx="35.81411"
cy="113.6531"
r="4.543582" />
<circle
r="4.543582"
cy="139.57825"
cx="62.006527"
id="circle2639-9"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2641-1"
cx="100.22607"
cy="104.56594"
r="4.543582" />
<circle
r="4.543582"
cy="153.74353"
cx="106.106"
id="circle2643-6"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2645-4"
cx="34.745033"
cy="157.21803"
r="4.543582" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 39.28862,158.01984 62.2738,-4.00904"
id="path2647-2"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 102.89877,150.26903 66.01557,141.7164"
id="path2649-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 58.532024,136.90555 38.219542,116.86034"
id="path2651-8"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 64.144685,135.5692 97.018839,107.77317"
id="path2653-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
r="4.543582"
cy="132.09471"
cx="123.74581"
id="circle2655-2"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 66.550108,138.50917 52.117552,-5.07812"
id="path2657-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2659-3"
cx="151.8091"
cy="164.96886"
r="4.543582" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path2661-9"
d="m 126.95302,135.03467 21.9161,26.19241"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="path2637-7-5"
cx="40.892231"
cy="206.12836"
r="4.543582" />
<circle
r="4.543582"
cy="232.05351"
cx="67.084648"
id="circle2639-9-6"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2641-1-6"
cx="105.30419"
cy="197.0412"
r="4.543582" />
<circle
r="4.543582"
cy="246.2188"
cx="111.18412"
id="circle2643-6-5"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2645-4-3"
cx="39.823154"
cy="249.6933"
r="4.543582" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 44.366743,250.4951 62.273797,-4.00904"
id="path2647-2-6"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 107.97689,242.74429 71.093692,234.19166"
id="path2649-7-7"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 63.610148,229.38081 43.297664,209.3356"
id="path2651-8-9"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 69.222807,228.04446 102.09696,200.24843"
id="path2653-3-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
r="4.543582"
cy="224.56998"
cx="128.82394"
id="circle2655-2-1"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 71.628232,230.98443 123.74578,225.9063"
id="path2657-7-4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2659-3-7"
cx="156.88722"
cy="257.44412"
r="4.543582" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path2661-9-1"
d="m 132.03114,227.50993 21.91611,26.19241"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="path2637-7-5-4"
cx="211.41019"
cy="26.790506"
r="4.543582" />
<circle
r="4.543582"
cy="52.71566"
cx="237.6026"
id="circle2639-9-6-3"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2641-1-6-0"
cx="275.82214"
cy="17.703333"
r="4.543582" />
<circle
r="4.543582"
cy="66.880928"
cx="281.70209"
id="circle2643-6-5-2"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2645-4-3-0"
cx="210.34111"
cy="70.355446"
r="4.543582" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 214.8847,71.157246 62.27379,-4.00904"
id="path2647-2-6-9"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 278.49484,63.406436 -36.88319,-8.55263"
id="path2649-7-7-6"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 234.1281,50.042956 213.81562,29.997746"
id="path2651-8-9-3"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 239.74076,48.706606 32.87415,-27.79603"
id="path2653-3-3-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
r="4.543582"
cy="45.232124"
cx="299.34189"
id="circle2655-2-1-1"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 242.14619,51.646576 52.11754,-5.07814"
id="path2657-7-4-8"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2659-3-7-4"
cx="327.40518"
cy="78.106255"
r="4.543582" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path2661-9-1-0"
d="m 302.54909,48.172076 21.91611,26.19241"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="path2637-7-5-4-0"
cx="223.70457"
cy="119.80031"
r="4.543582" />
<circle
r="4.543582"
cy="145.72546"
cx="249.89699"
id="circle2639-9-6-3-4"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2641-1-6-0-5"
cx="288.11655"
cy="110.71313"
r="4.543582" />
<circle
r="4.543582"
cy="159.89073"
cx="293.99649"
id="circle2643-6-5-2-8"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2645-4-3-0-1"
cx="222.6355"
cy="163.36525"
r="4.543582" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 227.1791,164.16705 62.27379,-4.00904"
id="path2647-2-6-9-3"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 290.78924,156.41624 -36.88319,-8.55263"
id="path2649-7-7-6-4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 246.4225,143.05276 226.11002,123.00755"
id="path2651-8-9-3-7"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#ff0000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 252.03516,141.71641 32.87415,-27.79603"
id="path2653-3-3-5-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
r="4.543582"
cy="138.24193"
cx="311.63629"
id="circle2655-2-1-1-4"
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke" />
<path
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 254.44059,144.65638 52.11754,-5.07814"
id="path2657-7-4-8-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<circle
style="opacity:1;vector-effect:none;fill:#ff0000;fill-opacity:1;stroke:#080300;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers fill stroke"
id="circle2659-3-7-4-1"
cx="339.69958"
cy="171.11606"
r="4.543582" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path2661-9-1-0-3"
d="m 314.84349,141.18188 21.91611,26.19241"
style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</svg>

+ 131
- 0
experiments/decagon_run_effcat/decagon_run_effcat.py Просмотреть файл

@@ -0,0 +1,131 @@
#!/usr/bin/env python3
from icosagon.data import Data
from icosagon.trainprep import TrainValTest, \
prepare_training
from icosagon.model import Model
from icosagon.trainloop import TrainLoop
import os
import pandas as pd
from bisect import bisect_left
import torch
import sys
def index(a, x):
i = bisect_left(a, x)
if i != len(a) and a[i] == x:
return i
raise ValueError
def load_data(dev):
path = '/pstore/data/data_science/ref/decagon'
df_combo = pd.read_csv(os.path.join(path, 'bio-decagon-combo.csv'))
df_effcat = pd.read_csv(os.path.join(path, 'bio-decagon-effectcategories.csv'))
df_mono = pd.read_csv(os.path.join(path, 'bio-decagon-mono.csv'))
df_ppi = pd.read_csv(os.path.join(path, 'bio-decagon-ppi.csv'))
df_tgtall = pd.read_csv(os.path.join(path, 'bio-decagon-targets-all.csv'))
df_tgt = pd.read_csv(os.path.join(path, 'bio-decagon-targets.csv'))
lst = [ 'df_combo', 'df_effcat', 'df_mono', 'df_ppi', 'df_tgtall', 'df_tgt' ]
for nam in lst:
print(f'len({nam}): {len(locals()[nam])}')
print(f'{nam}.columns: {locals()[nam].columns}')
genes = set()
genes = genes.union(df_ppi['Gene 1']).union(df_ppi['Gene 2']) \
.union(df_tgtall['Gene']).union(df_tgt['Gene'])
genes = sorted(genes)
print('len(genes):', len(genes))
drugs = set()
drugs = drugs.union(df_combo['STITCH 1']).union(df_combo['STITCH 2']) \
.union(df_mono['STITCH']).union(df_tgtall['STITCH']).union(df_tgt['STITCH'])
drugs = sorted(drugs)
print('len(drugs):', len(drugs))
data = Data()
data.add_node_type('Gene', len(genes))
data.add_node_type('Drug', len(drugs))
print('Preparing PPI...')
print('Indexing rows...')
rows = [index(genes, g) for g in df_ppi['Gene 1']]
print('Indexing cols...')
cols = [index(genes, g) for g in df_ppi['Gene 2']]
indices = list(zip(rows, cols))
indices = torch.tensor(indices).transpose(0, 1)
values = torch.ones(len(rows))
print('indices.shape:', indices.shape, 'values.shape:', values.shape)
adj_mat = torch.sparse_coo_tensor(indices, values, size=(len(genes),) * 2,
device=dev)
adj_mat = (adj_mat + adj_mat.transpose(0, 1)) / 2
print('adj_mat created')
fam = data.add_relation_family('PPI', 0, 0, True)
rel = fam.add_relation_type('PPI', adj_mat)
print('OK')
print('Preparing Drug-Gene (Target) edges...')
rows = [index(drugs, d) for d in df_tgtall['STITCH']]
cols = [index(genes, g) for g in df_tgtall['Gene']]
indices = list(zip(rows, cols))
indices = torch.tensor(indices).transpose(0, 1)
values = torch.ones(len(rows))
adj_mat = torch.sparse_coo_tensor(indices, values, size=(len(drugs), len(genes)),
device=dev)
fam = data.add_relation_family('Drug-Gene (Target)', 1, 0, True)
rel = fam.add_relation_type('Drug-Gene (Target)', adj_mat)
print('OK')
df_combo_effcat = df_combo.merge(df_effcat, left_on='Polypharmacy Side Effect', right_on='Side Effect')
disease_classes = []
print('Preparing Drug-Drug (Side Effect) edges...')
fam = data.add_relation_family('Drug-Drug (Side Effect)', 1, 1, True)
print('# of side effects:', len(df_combo), 'unique:', len(df_combo['Polypharmacy Side Effect'].unique()))
for discls, df in df_combo_effcat.groupby('Disease Class'):
disease_classes.append(discls)
sys.stdout.write('.') # print(eff, '...')
sys.stdout.flush()
rows = [index(drugs, d) for d in df['STITCH 1']]
cols = [index(drugs, d) for d in df['STITCH 2']]
indices = list(zip(rows, cols))
indices = torch.tensor(indices).transpose(0, 1)
values = torch.ones(len(rows))
adj_mat = torch.sparse_coo_tensor(indices, values, size=(len(drugs), len(drugs)),
device=dev)
adj_mat = (adj_mat + adj_mat.transpose(0, 1)) / 2
rel = fam.add_relation_type(df['Polypharmacy Side Effect'], adj_mat)
print()
print('len(disease_classes):', len(disease_classes))
print('OK')
return data
def _wrap(obj, method_name):
orig_fn = getattr(obj, method_name)
def fn(*args, **kwargs):
print(f'{method_name}() :: ENTER')
res = orig_fn(*args, **kwargs)
print(f'{method_name}() :: EXIT')
return res
setattr(obj, method_name, fn)
def main():
dev = torch.device('cuda:0')
data = load_data(dev)
prep_d = prepare_training(data, TrainValTest(.8, .1, .1))
_wrap(Model, 'build')
model = Model(prep_d)
model = model.to(dev)
# model = torch.nn.DataParallel(model, ['cuda:0', 'cuda:1'])
_wrap(TrainLoop, 'build')
_wrap(TrainLoop, 'run_epoch')
loop = TrainLoop(model, batch_size=512, shuffle=True)
loop.run_epoch()
if __name__ == '__main__':
main()

+ 28
- 0
src/icosagon/compile.py Просмотреть файл

@@ -0,0 +1,28 @@
#
# The goal of this module is to make Icosagon more efficient.
# It takes the nice Icosagon model architecture and tries to
# formulate it in terms of batch matrix multiplications instead
# of using Python for loops.
#
from .weights import init_glorot
from .input
import torch
class EncodeLayer(object):
def __init__(self, num_relation_types, input_dim, output_dim):
weights = [ init_glorot(input_dim, output_dim) \
for _ in range(num_relation_types) ]
weights = torch.cat(weights)
class Compiler(object):
def __init__(self, data: Data, layer_dimensions: List[int] = [32, 64]) -> None:
self.data = data
self.layer_dimensions = layer_dimensions
self.build()
def build(self) -> None:
for fam in data.relation_families:
init_glorot(in_channels, out_channels)

+ 33
- 0
tests/icosagon/test_trainloop.py Просмотреть файл

@@ -79,3 +79,36 @@ def test_timing_01():
for _ in range(1300):
_ = torch.sparse.mm(adj_mat, rep)
print('Elapsed:', time.time() - t)
def test_timing_02():
adj_mat = (torch.rand(2000, 2000) < .001).to(torch.float32)
adj_mat_batch = [adj_mat.view(1, 2000, 2000)] * 1300
adj_mat_batch = torch.cat(adj_mat_batch)
rep = torch.eye(2000).requires_grad_(True)
t = time.time()
res = torch.matmul(adj_mat_batch, rep)
print('Elapsed:', time.time() - t)
print('res.shape:', res.shape)
def test_timing_03():
adj_mat = (torch.rand(2000, 2000) < .001).to(torch.float32)
adj_mat_batch = [adj_mat.view(1, 2000, 2000).to_sparse()] * 1300
adj_mat_batch = torch.cat(adj_mat_batch)
rep = torch.eye(2000).requires_grad_(True)
rep_batch = [rep.view(1, 2000, 2000)] * 1300
rep_batch = torch.cat(rep_batch)
t = time.time()
with pytest.raises(RuntimeError):
_ = torch.bmm(adj_mat_batch, rep)
print('Elapsed:', time.time() - t)
def test_timing_04():
adj_mat = (torch.rand(2000, 2000) < .0001).to(torch.float32).to_sparse()
rep = torch.eye(2000).requires_grad_(True)
t = time.time()
for _ in range(1300):
_ = torch.sparse.mm(adj_mat, rep)
print('Elapsed:', time.time() - t)

Загрузка…
Отмена
Сохранить