提交 f8740749 authored 作者: Christof Angermueller's avatar Christof Angermueller

Improve layout d3printing and add examples

上级 40f8ae2e
<!DOCTYPE html>
<html>
<head lang='en'>
<meta charset="utf-8">
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type='text/javascript' src="http://cpettitt.github.io/project/dagre-d3/v0.1.5/dagre-d3.min.js"></script>
<script type='text/javascript' src="http://cpettitt.github.io/project/graphlib-dot/v0.4.10/graphlib-dot.min.js"></script>
</head>
<body>
<style>
.svg {
}
.nodeRect {
stroke: black;
border: 3px solid black;
fill: lightsteelblue;
}
.nodeText {
color: black;
font-family: courier;
}
.edge {
stroke: black;
stroke-width: 3px;
}
.edgeLabelRect {
fill: white;
}
.edgeLabelText {
fill: limegreen;
font-family: courier;
text-anchor: start;
}
.arrowHead {
stroke: black;
stroke-width: 3px;
fill: black;
}
</style>
<script type="text/javascript">
// Global attributes
var dotGraphDef = 'digraph G { graph [bb="0,0,763,388"]; "DimShuffle{x,0}" [height=0.5, pos="600,282", shape=ellipse, width=2.0339]; "Elemwise{add,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="474,194", shape=ellipse, style=filled, width=3.0624]; "DimShuffle{x,0}" -> "Elemwise{add,no_inplace}" [label="1 TensorType(float64, row)", lp="648,238", pos="e,516.94,210.65 587.13,264.21 578.18,253.39 565.47,239.59 552,230 544.1,224.38 535.16,219.35 526.22,214.97"]; "name=b TensorType(float64, vector)" [fillcolor=green, height=0.5, pos="607,370", shape=box, style=filled, width=3.0903]; "name=b TensorType(float64, vector)" -> "DimShuffle{x,0}" [label="TensorType(float64, vector)", lp="684,326", pos="e,601.39,300.08 605.58,351.6 604.62,339.75 603.32,323.82 602.22,310.29"]; dot [height=0.5, pos="362,282", shape=ellipse, width=0.75]; dot -> "Elemwise{add,no_inplace}" [label="0 TensorType(float64, matrix)", lp="467,238", pos="e,414.72,209.23 365,263.89 367.74,252.92 372.81,239.1 382,230 388.76,223.31 396.93,217.87 405.58,213.46"]; "name=X TensorType(float64, matrix)" [fillcolor=green, height=0.5, pos="114,370", shape=box, style=filled, width=3.1667]; "name=X TensorType(float64, matrix)" -> dot [label="0 TensorType(float64, matrix)", lp="273,326", pos="e,335.37,285 134.04,351.84 148.22,340.57 168.18,326.4 188,318 233.06,298.9 289.18,290.03 325.29,286.04"]; "name=W TensorType(float64, matrix)" [fillcolor=green, height=0.5, pos="362,370", shape=box, style=filled, width=3.2014]; "name=W TensorType(float64, matrix)" -> dot [label="1 TensorType(float64, matrix)", lp="447,326", pos="e,362,300.08 362,351.6 362,339.75 362,323.82 362,310.29"]; Softmax [height=0.5, pos="474,106", shape=ellipse, width=1.1472]; "Elemwise{add,no_inplace}" -> Softmax [label="TensorType(float64, matrix)", lp="554,150", pos="e,474,124.08 474,175.6 474,163.75 474,147.82 474,134.29"]; "TensorType(float64, matrix) id=6" [fillcolor=blue, height=0.5, pos="474,18", shape=box, style=filled, width=2.8403]; Softmax -> "TensorType(float64, matrix) id=6" [label="TensorType(float64, matrix)", lp="554,62", pos="e,474,36.084 474,87.597 474,75.746 474,59.817 474,46.292"]; } ';
var width = 800;
var height = 600;
// Add SVG element
var svg = d3.select('body').append('svg').attr('class', 'svg').attr('width', width).attr('height', height);
var pane = svg.append('g').attr('transform', 'scale(0.8)');
// Definition head of edges
svg.append("defs").append("marker")
.attr("id", 'markerEnd')
.attr("markerWidth", 6)
.attr("markerHeight", 6)
.attr("refX", 5)
.attr("refY", 3)
.attr("orient", "auto")
.append("path")
.attr("d", "M0,0 L6,3 L0,6 Z")
.attr('style', 'arrowHead');
function textWidth(text) {
return text.length * 10.5;
}
// Parse dot graph definition
var graph = {};
var nodes = [];
var edges = [];
var dotGraph = graphlibDot.parse(dotGraphDef);
// TODO: parse from file
var dotWidth = 763;
var dotHeight = 388;
var scaleDotX = d3.scale.linear().domain([0, dotWidth]).range([0, width]);
var scaleDotY = d3.scale.linear().domain([0, dotHeight]).range([0, height]);
// Parse nodes
var i = 0;
for (nodeId in dotGraph._nodes) {
var node = dotGraph._nodes[nodeId];
node.index = i++;
node.value.width = textWidth(node.value.label);
node.value.height = 40;
node.value.cx = node.value.width / 2;
node.value.cy = node.value.height / 2;
node.value.pos = node.value.pos.split(',').map(function(d) {return parseInt(d);});
node.x = scaleDotX(node.value.pos[0]);
node.y = scaleDotY(dotHeight - node.value.pos[1]);
node.fixed = false;
nodes.push(node);
dotGraph._nodes[nodeId] = node;
}
// Parse edges
for (edgeId in dotGraph._edges) {
var edge = dotGraph._edges[edgeId];
edge.source = dotGraph._nodes[edge.u].index;
edge.target = dotGraph._nodes[edge.v].index;
edge.value.width = textWidth(edge.value.label);
edge.value.height = 40;
edges.push(edge);
dotGraph._edges[edgeId] = edge;
}
// Setup graph
graph['nodes'] = nodes;
graph['edges'] = edges;
// Add edges
edges = pane.append('g').attr('id', 'edges').selectAll('path').data(graph['edges']).enter().append('path')
.attr('class', 'edge')
.attr('marker-end', 'url(#markerEnd)');
// Add edge labels
edgeLabels = pane.append('g').attr('id', 'edgeLabels').selectAll('g').data(graph['edges']).enter().append('g')
.attr('opacity', 0)
.on('mouseover', function(d) {d3.select(this).attr('opacity', 1.0);})
.on('mouseout', function(d) {d3.select(this).attr('opacity', 0.0);});
var edgeLabelsRect = edgeLabels.append('rect')
.attr('class', 'edgeLabelRect')
.attr('fill', 'white')
.attr('width', function(d) {return d.value.width;})
.attr('height', function(d) {return d.value.height;});
var edgeLabelsText = edgeLabels.append('text')
.attr('class', 'edgeLabelText')
.attr('dy', function(d) {return 0.5 * d.value.height;})
.text(function(d) {return d.value.label;});
// Add nodes
nodes = pane.append('g').attr('id', 'nodes').selectAll('g').data(graph['nodes']).enter().append('g');
var nodesRect = nodes.append('rect')
.attr('class', 'nodeRect')
.attr('width', function(d) {return d.value.width;})
.attr('height', function(d) {return d.value.height;});
var nodesText = nodes.append('text')
.attr('class', 'nodeText')
.attr('x', 5)
.attr('dy', function(d) {return d.value.height - 15;})
.text(function(d) {return d.value.label;});
// Update graph
function update() {
// Update nodes
nodes.attr('transform', function(d) { return 'translate(' + d.x + ' ' + d.y + ')'; });
// Update edges
edges.attr('d', function(d) {
return 'M' + (d.source.x + d.source.value.cx) + ',' + (d.source.y + d.source.value.cy) + ' L' + (d.target.x + d.target.value.cx) + ',' + (d.target.y - 3);
});
// Update edge labels
edgeLabels.attr('transform', function(d) {
return 'translate(' + (0.5 * (d.source.x + d.source.value.cx + d.target.x + d.target.value.cx) - 0.5 * d.value.width) + ',' + (0.5 * (d.source.y + d.source.value.cy + d.target.y + d.target.value.cy) - 0.5 * d.value.height) + ')';
});
}
// Drag-start event handler
function dragStart(d) {
d3.event.sourceEvent.stopPropagation();
d.fixed = true;
}
// Zoom and translate event handler
function zoom(d) {
pane.attr('transform', 'translate(' + d3.event.translate + ') scale(' + d3.event.scale + ')');
}
// Force layout
var layout = d3.layout.force()
.nodes(graph['nodes'])
.links(graph['edges'])
.size([width, height])
.gravity(0.2)
.charge(-6000)
.linkDistance(75)
.linkStrength(0.1)
.on('tick', update);
// Drag behavour
var drag = layout.drag()
.on('dragstart', dragStart);
nodes.call(drag);
// Zoom behaviour
var bZoom = d3.behavior.zoom()
.scaleExtent([0.2, 8])
.on('zoom', zoom);
svg.call(bZoom);
// Start force layout
layout.start();
</script>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 1,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"The autoreload extension is already loaded. To reload it, use:\n", "Couldn't import dot_parser, loading of dot files will not be possible.\n"
" %reload_ext autoreload\n"
] ]
} }
], ],
...@@ -20,8 +19,7 @@ ...@@ -20,8 +19,7 @@
"import numpy as np\n", "import numpy as np\n",
"import theano\n", "import theano\n",
"import theano.tensor as T\n", "import theano.tensor as T\n",
"import theano.d3printing as d3p\n", "import theano.d3printing.d3printing as d3p\n",
"from IPython.display import HTML\n",
"\n", "\n",
"%load_ext autoreload\n", "%load_ext autoreload\n",
"%autoreload 2" "%autoreload 2"
...@@ -29,7 +27,7 @@ ...@@ -29,7 +27,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 2,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -41,12 +39,13 @@ ...@@ -41,12 +39,13 @@
"W = theano.shared(np.random.randn(num_in, num_out), name='W', borrow=True)\n", "W = theano.shared(np.random.randn(num_in, num_out), name='W', borrow=True)\n",
"b = theano.shared(np.random.randn(num_out), name='b', borrow=True)\n", "b = theano.shared(np.random.randn(num_out), name='b', borrow=True)\n",
"X = T.dmatrix('X')\n", "X = T.dmatrix('X')\n",
"y = T.nnet.softmax(X.dot(W) + b)" "y = T.nnet.softmax(X.dot(W) + b)\n",
"pred = y > 0.5"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 3,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -55,22 +54,48 @@ ...@@ -55,22 +54,48 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"The output file is available at logreg.html\n" "The output file is available at logreg_y.html\n"
] ]
} }
], ],
"source": [ "source": [
"html = d3p.d3print(y, 'logreg.html', return_html=True)" "d3p.d3print(y, 'logreg_y.html')"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "markdown",
"execution_count": null,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
"outputs": [], "source": [
"source": [] "[open](./logreg_y.html)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The output file is available at logreg_pred.html\n"
]
}
],
"source": [
"d3p.d3print(pred, 'logreg_pred.html')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[open](./logreg_pred.html)"
]
} }
], ],
"metadata": { "metadata": {
......
差异被折叠。
差异被折叠。
...@@ -51,8 +51,6 @@ def d3print(fct, outfile=None, return_html=False, print_message=True, ...@@ -51,8 +51,6 @@ def d3print(fct, outfile=None, return_html=False, print_message=True,
f.close() f.close()
replace = { replace = {
'%% DOT_GRAPH %%': dot_graph, '%% DOT_GRAPH %%': dot_graph,
'%% WIDTH %%': width,
'%% HEIGHT %%': height
} }
html = replace_patterns(template, replace) html = replace_patterns(template, replace)
......
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type='text/javascript' src="http://cpettitt.github.io/project/dagre-d3/v0.1.5/dagre-d3.min.js"></script>
<script type='text/javascript' src="http://cpettitt.github.io/project/graphlib-dot/v0.4.10/graphlib-dot.min.js"></script>
</head>
<body>
<style>
.svg {
margin-left:auto;
margin-right:auto;
display:block;
position: fixed;
border: 0px solid black;
top:0%; left:0%; right:0% bottom=0%
}
.nodeRect {
stroke: black;
border: 3px solid black;
}
.nodeEllipse {
stroke: black;
border: 3px solid black;
}
.nodeText {
color: black;
}
.edge {
stroke: black;
stroke-width: 3px;
cursor: pointer;
}
.edgeLabelRect {
stroke: black;
border: 1px solid black;
fill: skyblue;
opacity: 0.9;
}
.edgeLabelText {
fill: black;
text-anchor: start;
}
.arrowHead {
stroke: black;
stroke-width: 3px;
fill: black;
}
</style>
<script type="text/javascript">
var path='logreg.dot';
var width = 1200;
var height = 900;
// Global attributes
var pad = 10;
d3.select('body').select('svg').remove();
var svg = d3.select('body').append('svg')
.attr('class', 'svg')
.attr('width', '100%')
.attr('height', '100%');
var pane = svg.append('g');
// Definition head of edges
svg.append("defs").append("marker")
.attr("id", 'edgeArrow')
.attr("markerWidth", 6)
.attr("markerHeight", 6)
.attr("refX", 3)
.attr("refY", 3)
.attr("orient", "auto")
.append("path")
.attr("d", "M0,0 L6,3 L0,6 Z")
.attr('style', 'arrowHead');
function textSize(text, attr) {
var t = svg.append('text').text(text);
if (typeof(attr) != 'undefined') {
for (a in attr) {
t.attr(a, attr[a]);
}
}
var bbox = t.node().getBBox();
t.remove();
return bbox;
}
var dotGraph;
var graph = {};
var nodes = [];
var edges = [];
d3.text(path, function(data) {
dotGraph = graphlibDot.parse(data);
// Calculate width and height
var posMax = [0, 0];
for (var nodeId in dotGraph._nodes) {
var node = dotGraph._nodes[nodeId];
node.value.pos = node.value.pos.split(',').map(function(d) {return parseInt(d);});
node.value.width = parseInt(node.value.width);
node.value.height = parseInt(node.value.height);
posMax[0] = Math.max(posMax[0], node.value.pos[0] + node.value.width);
posMax[1] = Math.max(posMax[1], node.value.pos[1] + node.value.height);
}
dotWidth = posMax[0];
dotHeight = posMax[1];
svg.attr('viewBox', '0,0,' + width + ',' + height);
var scaleDotX = d3.scale.linear().domain([0, dotWidth + 100]).range([0, width]);
var scaleDotY = d3.scale.linear().domain([-25, dotHeight + 100]).range([0, height]);
// Parse nodes
var i = 0;
for (nodeId in dotGraph._nodes) {
var node = dotGraph._nodes[nodeId];
node.index = i++;
// x, y is center of node (not corner)
node.x = scaleDotX(node.value.pos[0]);
node.y = scaleDotY(dotHeight - (node.value.pos[1] + node.value.height));
var size = textSize(node.value.label, {'class': 'nodeText'});
node.value.width = size.width + 2 * pad;
node.value.height = size.height + 2 * pad;
node.value.cx = node.value.width / 2;
node.value.cy = node.value.height / 2;
node.fixed = true;
nodes.push(node);
dotGraph._nodes[nodeId] = node;
}
// Parse edges
for (edgeId in dotGraph._edges) {
var edge = dotGraph._edges[edgeId];
edge.source = dotGraph._nodes[edge.u].index;
edge.target = dotGraph._nodes[edge.v].index;
var size = textSize(edge.value.label, {'class': 'edgeLabelText'});
edge.value.width = size.width + 2 * pad;
edge.value.height = size.height + 2 * pad;
edges.push(edge);
dotGraph._edges[edgeId] = edge;
}
// Setup graph
graph['nodes'] = nodes;
graph['edges'] = edges;
var isEdgeOver = false;
var isEdgeLabelOver = false;
// Add edges
edges = pane.append('g').attr('id', 'edges').selectAll('path').data(graph['edges']).enter().append('path')
.attr('class', 'edge')
.attr('marker-mid', 'url(#edgeArrow)')
.on('mouseover', function(d) {
var edgeLabel = pane.select('#edgeLabels .' + d.id);
edgeLabel.attr('style', 'display: inline');
})
.on('mouseout', function(d) {
if (!isEdgeLabelOver) {
var edgeLabel = pane.select('#edgeLabels .' + d.id);
edgeLabel.attr('style', 'display: none');
}
});
// Add edge labels
edgeLabels = pane.append('g').attr('id', 'edgeLabels').selectAll('g').data(graph['edges']).enter().append('g')
.attr('style', 'display: none')
.attr('class', function(d) {return d.id;})
.on('mouseover', function(d) {
isEdgeLabelOver = true;
var edgeLabel = d3.select(this);
edgeLabel.attr('style', 'display: inline');
})
.on('mouseout', function(d) {
var edgeLabel = d3.select(this);
edgeLabel.attr('style', 'display: none');
isEdgeLabelOver = false;
});
var edgeLabelsRect = edgeLabels.append('rect')
.attr('class', 'edgeLabelRect')
.attr('fill', 'white')
.attr('width', function(d) {return d.value.width;})
.attr('height', function(d) {return d.value.height;})
.attr('rx', 5)
.attr('ry', 5);
var edgeLabelsText = edgeLabels.append('text')
.attr('class', 'edgeLabelText')
.attr('x', function(d) {return pad;})
.attr('dy', function(d) {return d.value.height - pad - 5;})
.text(function(d) {return d.value.label;});
// Add nodes
nodes = pane.append('g').attr('id', 'nodes').selectAll('g').data(graph['nodes']).enter().append('g');
function fillColor(f) {
return typeof(f) == 'undefined' ? 'white' : f;
}
nodes.each(function(d) {
sel = d3.select(this);
var shape;
if (d.value.shape == 'ellipse') {
shape = sel.append('ellipse')
.attr('class', 'nodeEllipse')
.attr('cx', d.value.cx)
.attr('cy', d.value.cy)
.attr('rx', d.value.width * 0.6)
.attr('ry', d.value.height * 0.6);
} else {
shape = sel.append('rect')
.attr('class', 'nodeRect')
.attr('width', d.value.width)
.attr('height', d.value.height);
}
shape.attr('fill', fillColor(d.value.fillcolor));
});
var nodesText = nodes.append('text')
.attr('class', 'nodeText')
.attr('x', pad)
.attr('dy', function(d) {return d.value.height - pad - 5;})
.text(function(d) {return d.value.label;});
// Update graph
function updateGraph() {
// Update nodes
nodes.attr('transform', function(d) { return 'translate(' + (d.x - d.value.cx) + ' ' + (d.y - d.value.cy) + ')'; });
// Update edges
edges.attr('d', function(d) {
return 'M' + d.source.x + ',' + d.source.y + ' L' + 0.5 * (d.source.x + d.target.x) + ',' + 0.5 * (d.source.y + d.target.y) + ' L' + d.target.x + ',' + d.target.y;
});
// Update edge labels
edgeLabels.attr('transform', function(d) {
return 'translate(' + (0.5 * (d.source.x + d.target.x - d.value.width)) + ',' + (0.5 * (d.source.y + d.target.y - d.value.height)) + ')';
});
}
// Drag-start event handler
function dragStart(d) {
d3.event.sourceEvent.stopPropagation();
d.fixed = true;
}
// Zoom and translate event handler
function zoom(d) {
pane.attr('transform', 'translate(' + d3.event.translate + ') scale(' + d3.event.scale + ')');
}
// Force layout
var layout = d3.layout.force()
.nodes(graph['nodes'])
.links(graph['edges'])
.size([width, height])
.gravity(0.00)
.charge(-1000)
.linkDistance(50)
.linkStrength(0.1)
.on('tick', updateGraph);
// Drag behavour
var drag = layout.drag()
.on('dragstart', dragStart);
nodes.call(drag);
// Zoom behaviour
var bZoom = d3.behavior.zoom()
.scaleExtent([0.2, 8])
.on('zoom', zoom);
svg.call(bZoom);
// Start force layout
layout.start();
});
</script>
</body>
</html>
digraph G { graph [bb="0,0,845,760"]; "DimShuffle{x}" [height=0.5, pos="593,194", shape=ellipse, width=1.8374]; "Elemwise{gt,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="485,106", shape=ellipse, style=filled, width=2.8978]; "DimShuffle{x}" -> "Elemwise{gt,no_inplace}" [label="1 TensorType(float32, (True,))", lp="658.5,150", pos="e,527.05,122.58 584.45,176.15 578.28,165.3 569.09,151.5 558,142 551.48,136.41 543.91,131.5 536.17,127.26"]; "val=0.5 TensorType(float32, scalar)" [fillcolor=limegreen, height=0.5, pos="606,282", shape=box, style=filled, width=3.0278]; "val=0.5 TensorType(float32, scalar)" -> "DimShuffle{x}" [label="TensorType(float32, scalar)", lp="679,238", pos="e,595.58,212.08 603.37,263.6 601.58,251.75 599.17,235.82 597.13,222.29"]; "DimShuffle{x} id=1" [height=0.5, pos="350,566", shape=ellipse, width=2.3721]; "Elemwise{sub,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="461,478", shape=ellipse, style=filled, width=3.0624]; "DimShuffle{x} id=1" -> "Elemwise{sub,no_inplace}" [label="1 TensorType(float64, (True,))", lp="440.5,522", pos="e,385.39,491.23 346.85,547.67 345.89,536.89 346.64,523.35 354,514 360.01,506.36 367.72,500.37 376.25,495.67"]; "name=b TensorType(float64, scalar)" [fillcolor=limegreen, height=0.5, pos="350,654", shape=box, style=filled, width=3.0625]; "name=b TensorType(float64, scalar)" -> "DimShuffle{x} id=1" [label="TensorType(float64, scalar)", lp="428,610", pos="e,350,584.08 350,635.6 350,623.75 350,607.82 350,594.29"]; dot [height=0.5, pos="564,654", shape=ellipse, width=0.75]; "Elemwise{neg,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="564,566", shape=ellipse, style=filled, width=3.0624]; dot -> "Elemwise{neg,no_inplace}" [label="TensorType(float64, vector)", lp="643,610", pos="e,564,584.08 564,635.6 564,623.75 564,607.82 564,594.29"]; "name=x TensorType(float64, matrix)" [fillcolor=limegreen, height=0.5, pos="442,742", shape=box, style=filled, width=3.1181]; "name=x TensorType(float64, matrix)" -> dot [label="0 TensorType(float64, matrix)", lp="579,698", pos="e,541.56,664.07 456.77,724 466.61,713.35 480.21,699.84 494,690 505.81,681.57 519.95,674.09 532.42,668.22"]; "name=w TensorType(float64, vector)" [fillcolor=limegreen, height=0.5, pos="686,742", shape=box, style=filled, width=3.1389]; "name=w TensorType(float64, vector)" -> dot [label="1 TensorType(float64, vector)", lp="760.5,698", pos="e,590.41,658.28 682.35,723.78 679.2,712.78 673.59,698.94 664,690 646.54,673.73 621.08,664.96 600.23,660.27"]; "DimShuffle{x} id=3" [height=0.5, pos="247,390", shape=ellipse, width=2.3721]; "Elemwise{add,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="369,282", shape=ellipse, style=filled, width=3.0624]; "DimShuffle{x} id=3" -> "Elemwise{add,no_inplace}" [label="0 TensorType(int8, (True,))", lp="334,336", pos="e,290.21,294.6 244.34,371.76 242.92,355.96 243.54,332.85 256,318 262.8,309.89 271.45,303.63 280.91,298.8"]; "val=1 TensorType(int8, scalar)" [fillcolor=limegreen, height=0.5, pos="162,478", shape=box, style=filled, width=2.6389]; "val=1 TensorType(int8, scalar)" -> "DimShuffle{x} id=3" [label="TensorType(int8, scalar)", lp="305.5,434", pos="e,242.68,408.18 202.18,459.88 210.48,455 218.62,449.05 225,442 231.23,435.11 235.89,426.19 239.27,417.74"]; "DimShuffle{x} id=4" [height=0.5, pos="85,336", shape=ellipse, width=2.3721]; "val=1 TensorType(int8, scalar)" -> "DimShuffle{x} id=4" [label="TensorType(int8, scalar)", lp="151.5,434", pos="e,78.928,354.24 101.1,459.78 93.551,455.18 86.813,449.36 82,442 66.938,418.97 70.674,386.61 76.281,363.92"]; "Elemwise{true_div,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="369,194", shape=ellipse, style=filled, width=3.5561]; "DimShuffle{x} id=4" -> "Elemwise{true_div,no_inplace}" [label="0 TensorType(int8, (True,))", lp="172,282", pos="e,277.79,206.71 82.19,317.91 80.604,301.99 81.056,278.59 94,264 117.19,237.85 199.28,219.48 267.79,208.3"]; "Elemwise{neg,no_inplace}" -> "Elemwise{sub,no_inplace}" [label="0 TensorType(float64, vector)", lp="629.5,522", pos="e,501.82,494.86 555.83,547.71 550.08,536.96 541.53,523.42 531,514 525.02,508.65 518.07,503.9 510.93,499.77"]; "Elemwise{exp,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="461,390", shape=ellipse, style=filled, width=3.0624]; "Elemwise{sub,no_inplace}" -> "Elemwise{exp,no_inplace}" [label="TensorType(float64, vector)", lp="540,434", pos="e,461,408.08 461,459.6 461,447.75 461,431.82 461,418.29"]; "Elemwise{exp,no_inplace}" -> "Elemwise{add,no_inplace}" [label="1 TensorType(float64, vector)", lp="526.5,336", pos="e,394.8,299.6 452.54,372.02 444.46,356.82 431.28,334.48 416,318 412.01,313.7 407.43,309.56 402.74,305.73"]; "Elemwise{add,no_inplace}" -> "Elemwise{true_div,no_inplace}" [label="1 TensorType(float64, vector)", lp="453.5,238", pos="e,369,212.08 369,263.6 369,251.75 369,235.82 369,222.29"]; "Elemwise{true_div,no_inplace}" -> "Elemwise{gt,no_inplace}" [label="0 TensorType(float64, vector)", lp="469.5,150", pos="e,419.59,120.09 370.47,175.87 372.26,164.9 376.22,151.07 385,142 392.17,134.59 401,128.74 410.42,124.14"]; "TensorType(int8, vector)" [fillcolor=dodgerblue, height=0.5, pos="485,18", shape=box, style=filled, width=2.1736]; "Elemwise{gt,no_inplace}" -> "TensorType(int8, vector)" [label="TensorType(int8, vector)", lp="555.5,62", pos="e,485,36.084 485,87.597 485,75.746 485,59.817 485,46.292"]; }
digraph G { graph [bb="0,0,763,388"]; "DimShuffle{x,0}" [height=0.5, pos="600,282", shape=ellipse, width=2.0339]; "Elemwise{add,no_inplace}" [fillcolor="#FFAABB", height=0.5, pos="474,194", shape=ellipse, style=filled, width=3.0624]; "DimShuffle{x,0}" -> "Elemwise{add,no_inplace}" [label="1 TensorType(float64, row)", lp="648,238", pos="e,516.94,210.65 587.13,264.21 578.18,253.39 565.47,239.59 552,230 544.1,224.38 535.16,219.35 526.22,214.97"]; "name=b TensorType(float64, vector)" [fillcolor=limegreen, height=0.5, pos="607,370", shape=box, style=filled, width=3.0903]; "name=b TensorType(float64, vector)" -> "DimShuffle{x,0}" [label="TensorType(float64, vector)", lp="684,326", pos="e,601.39,300.08 605.58,351.6 604.62,339.75 603.32,323.82 602.22,310.29"]; dot [height=0.5, pos="362,282", shape=ellipse, width=0.75]; dot -> "Elemwise{add,no_inplace}" [label="0 TensorType(float64, matrix)", lp="467,238", pos="e,414.72,209.23 365,263.89 367.74,252.92 372.81,239.1 382,230 388.76,223.31 396.93,217.87 405.58,213.46"]; "name=X TensorType(float64, matrix)" [fillcolor=limegreen, height=0.5, pos="114,370", shape=box, style=filled, width=3.1667]; "name=X TensorType(float64, matrix)" -> dot [label="0 TensorType(float64, matrix)", lp="273,326", pos="e,335.37,285 134.04,351.84 148.22,340.57 168.18,326.4 188,318 233.06,298.9 289.18,290.03 325.29,286.04"]; "name=W TensorType(float64, matrix)" [fillcolor=limegreen, height=0.5, pos="362,370", shape=box, style=filled, width=3.2014]; "name=W TensorType(float64, matrix)" -> dot [label="1 TensorType(float64, matrix)", lp="447,326", pos="e,362,300.08 362,351.6 362,339.75 362,323.82 362,310.29"]; Softmax [height=0.5, pos="474,106", shape=ellipse, width=1.1472]; "Elemwise{add,no_inplace}" -> Softmax [label="TensorType(float64, matrix)", lp="554,150", pos="e,474,124.08 474,175.6 474,163.75 474,147.82 474,134.29"]; "TensorType(float64, matrix) id=6" [fillcolor=dodgerblue, height=0.5, pos="474,18", shape=box, style=filled, width=2.8403]; Softmax -> "TensorType(float64, matrix) id=6" [label="TensorType(float64, matrix)", lp="554,62", pos="e,474,36.084 474,87.597 474,75.746 474,59.817 474,46.292"]; }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论