20 lines
543 B
JavaScript
20 lines
543 B
JavaScript
"use strict";
|
|
|
|
import nomnoml from 'nomnoml';
|
|
|
|
export default function make_graph(summary) {
|
|
const result = [];
|
|
for(const layer of summary.layers) {
|
|
const output_shape = layer.output_shape.replace(/\[/, "\\[")
|
|
.replace(/\]/, "\\]");
|
|
result.push(`[${layer.name}|${layer.type}|Params: ${layer.params}|Output shape: ${output_shape}]`);
|
|
}
|
|
for(const edge of summary.edges) {
|
|
result.push(`[${edge.from}] --> [${edge.to}]`);
|
|
}
|
|
|
|
const nomnoml_source = result.join("\n");
|
|
|
|
const svg = nomnoml.renderSvg(nomnoml_source);
|
|
return svg;
|
|
} |