天道酬勤,学无止境

How to generate nodes with customized shape?

HERE is a very good example that illustrates how to generate complex graphs using graphviz. The dot file is listed here.

digraph G {
    compound=true;
    ranksep=1.25;
    label="From Past to Future...";

    node [shape=plaintext, fontsize=16];

    bgcolor=white;
    edge [arrowsize=1, color=black];

    /* Nodes */
    subgraph cluster_Computers {label="Computers"; labelloc="b"; Computers_icon};
    Computers_icon [label="", shape=box, style=invis, shapefile="Computers.png"];

    subgraph cluster_Semantic_Web {label="Semantic Web"; labelloc="b"; Semantic_Web_icon};
    Semantic_Web_icon [label="", shape=box, style=invis, shapefile="Semantic_Web.png"];

    subgraph cluster_Cryptography {label="Cryptography"; labelloc="b"; Cryptography_icon};
    Cryptography_icon [label="", shape=box, style=invis, shapefile="Cryptography.png"];

    subgraph cluster_Automata {label="Automata"; labelloc="b"; Automata_icon};
    Automata_icon [label="", shape=box, style=invis, shapefile="Automata.png"];

    subgraph cluster_AI {label="A.I."; labelloc="b"; AI_icon};
    AI_icon [label="", shape=box, style=invis, shapefile="AI.png"];

    subgraph cluster_Chaos {label="Chaos / Fractals"; labelloc="b"; Chaos_icon};
    Chaos_icon [label="", shape=box, style=invis, shapefile="Chaos.png"];

    subgraph cluster_XML {label="XML / RDF / URI"; labelloc="b"; XML_icon};
    XML_icon [label="", shape=box, style=invis, shapefile="XML.png"];

    subgraph cluster_Ontology {label="Ontology / Clustering"; labelloc="b"; Ontology_icon};
    Ontology_icon [label="", shape=box, style=invis, shapefile="Ontology.png"];

    subgraph cluster_Biology {label="Biology / Neurons"; labelloc="b"; Biology_icon};
    Biology_icon [label="", shape=box, style=invis, shapefile="Biology.png"];

    subgraph cluster_Agents {label="Agents / Security"; labelloc="b"; Agents_icon};
    Agents_icon [label="", shape=box, style=invis, shapefile="Agents.png"];

    subgraph cluster_Small_World {label="The Small World Project"; labelloc="b"; Small_World_icon};
    Small_World_icon [label="", shape=box, style=invis, shapefile="Small_World.png"];

    subgraph cluster_Social_Networks {label="Social Networks"; labelloc="b"; Social_Networks_icon};
    Social_Networks_icon [label="", shape=box, style=invis, shapefile="Social_Networks.png"];

    subgraph cluster_Search_Engines {label="Search Engines"; labelloc="b"; Search_Engines_icon};
    Search_Engines_icon [label="", shape=box, style=invis, shapefile="Search_Engines.png"];

    subgraph cluster_Turing {label="A. Turing"; labelloc="b"; Turing_icon};
    Turing_icon [label="", shape=box, style=invis, shapefile="Turing.png"];

    subgraph cluster_Rejewski {label="M. Rejewski"; labelloc="b"; Rejewski_icon};
    Rejewski_icon [label="", shape=box, style=invis, shapefile="Rejewski.png"];

    subgraph cluster_Dertouzos {label="M. Dertouzos"; labelloc="b"; Dertouzos_icon};
    Dertouzos_icon [label="", shape=box, style=invis, shapefile="Dertouzos.png"];

    subgraph cluster_Berners_Lee {label="T. Berners-Lee"; labelloc="b"; Berners_Lee_icon};
    Berners_Lee_icon [label="", shape=box, style=invis, shapefile="Berners_Lee.png"];

    /* Relationships */
    Computers_icon -> Semantic_Web_icon;
    Semantic_Web_icon -> Computers_icon;
    Cryptography_icon -> Semantic_Web_icon;
    Cryptography_icon -> Computers_icon;
    Automata_icon -> Computers_icon;
    AI_icon -> Automata_icon;
    Automata_icon -> AI_icon;
    Chaos_icon -> Computers_icon;
    Chaos_icon -> AI_icon;
    AI_icon -> Chaos_icon;
    Computers_icon -> Chaos_icon;
    XML_icon -> Semantic_Web_icon;
    XML_icon -> Computers_icon;
    Computers_icon -> XML_icon;
    Ontology_icon -> Semantic_Web_icon;
    Biology_icon -> AI_icon;
    Biology_icon -> Chaos_icon;
    Chaos_icon -> Biology_icon;
    Chaos_icon -> Semantic_Web_icon;
    Agents_icon -> Semantic_Web_icon;
    Semantic_Web_icon -> Agents_icon;
    Agents_icon -> AI_icon;
    AI_icon -> Agents_icon;
    Small_World_icon -> Chaos_icon;
    Small_World_icon -> Agents_icon;
    Small_World_icon -> Biology_icon;
    Biology_icon -> Small_World_icon;
    Social_Networks_icon -> Small_World_icon;
    Social_Networks_icon -> Biology_icon;
    Search_Engines_icon -> Semantic_Web_icon;
    Computers_icon -> Search_Engines_icon;
    Turing_icon -> Cryptography_icon;
    Turing_icon -> Computers_icon;
    Turing_icon -> Automata_icon;
    Rejewski_icon -> Turing_icon;
    Rejewski_icon -> Cryptography_icon;
    Dertouzos_icon -> Computers_icon;
    Dertouzos_icon -> Berners_Lee_icon;
    Berners_Lee_icon -> Semantic_Web_icon;


    { rank=same; Rejewski_icon; Turing_icon; Dertouzos_icon; Berners_Lee_icon };
    { rank=same; Biology_icon; AI_icon; Social_Networks_icon };

}

I run dot -Tpng -ofrom-past-to-future.png from-past-to-future.dot with warnings

C:\dot>dot -Tpng -ofrom-past-to-future.png from-past-to-future.dot
Warning: AI_icon was already in a rankset, deleted from cluster G
Warning: Biology_icon was already in a rankset, deleted from cluster G
Warning: Social_Networks_icon was already in a rankset, deleted from cluster G
Warning: Turing_icon was already in a rankset, deleted from cluster G
Warning: Rejewski_icon was already in a rankset, deleted from cluster G
Warning: Dertouzos_icon was already in a rankset, deleted from cluster G
Warning: Berners_Lee_icon was already in a rankset, deleted from cluster G

I tried to modify the dot file but could not get the same png image as the original post. How to approach it?

标签

评论

Here's a modified script which works with current versions of graphviz. Please note that you'll need to have all the images in the same directory as the script.

Changes I made:

  • Cleaned up redundant attribute declarations (label="", labelloc, etc.)
  • Used the image attribute instead of the old shapefile
  • Removed shape=box and style=invis from the nodes
  • Added penwidth=0 to get rid of the cluster border
  • Put the graph label at the bottom (should always be at the bottom)
  • Commented out the rank constraints. The same nodes cannot be part of different subgraphs.

This will not reproduce exactly the same graph, of course. Recreating the rank constraints will need some more creativity, mainly because each node is packed into its own cluster in order to attach a label to it... very hacky. You may try the same without clusters, but with the new xlabel attribute.

I added a second version, in which I uncommented the rank=same subgraphs and placed them before the definition of the clusters. Graphviz will then create an output, but without any labels for those nodes.

Here's the script:

digraph G {
    compound=true;
    ranksep=1.25;

    node [shape=plaintext, fontsize=16, label=""];

    bgcolor=white;
    edge [arrowsize=1, color=black];
    graph[penwidth=0, labelloc="b"];

    /* Nodes */
    //{ rank=same; Rejewski_icon; Turing_icon; Dertouzos_icon; Berners_Lee_icon };
    //{ rank=same; Biology_icon; AI_icon; Social_Networks_icon };

    subgraph cluster_Computers {label="Computers"; Computers_icon[image="Computers.png"];};
    subgraph cluster_Semantic_Web {label="Semantic Web"; Semantic_Web_icon[image="Semantic_Web.png"];};
    subgraph cluster_Cryptography {label="Cryptography"; Cryptography_icon[image="Cryptography.png"];};
    subgraph cluster_Automata {label="Automata"; Automata_icon[image="Automata.png"];};
    subgraph cluster_AI {label="A.I."; AI_icon[image="AI.png"];};
    subgraph cluster_Chaos {label="Chaos / Fractals"; Chaos_icon[image="Chaos.png"];};
    subgraph cluster_XML {label="XML / RDF / URI"; XML_icon[image="XML.png"];};
    subgraph cluster_Ontology {label="Ontology / Clustering"; Ontology_icon[image="Ontology.png"];};
    subgraph cluster_Biology {label="Biology / Neurons"; Biology_icon[image="Biology.png"];};
    subgraph cluster_Agents {label="Agents / Security"; Agents_icon[image="Agents.png"];};
    subgraph cluster_Small_World {label="The Small World Project"; Small_World_icon[image="Small_World.png"];};
    subgraph cluster_Social_Networks {label="Social Networks"; Social_Networks_icon[image="Social_Networks.png"];};
    subgraph cluster_Search_Engines {label="Search Engines"; Search_Engines_icon[image="Search_Engines.png"];};
    subgraph cluster_Turing {label="A. Turing"; Turing_icon[image="Turing.png"];};
    subgraph cluster_Rejewski {label="M. Rejewski"; Rejewski_icon[image="Rejewski.png"];};
    subgraph cluster_Dertouzos {label="M. Dertouzos"; Dertouzos_icon[image="Dertouzos.png"];};
    subgraph cluster_Berners_Lee {label="T. Berners-Lee"; Berners_Lee_icon[image="Berners_Lee.png"];};


    /* Relationships */
    Agents_icon -> {AI_icon Semantic_Web_icon};
    AI_icon -> {Agents_icon Automata_icon Chaos_icon};
    Automata_icon -> {AI_icon Computers_icon};
    Berners_Lee_icon -> Semantic_Web_icon;
    Biology_icon -> {AI_icon Chaos_icon Small_World_icon};
    Chaos_icon -> {AI_icon Biology_icon Computers_icon Semantic_Web_icon};
    Computers_icon -> {Chaos_icon Search_Engines_icon Semantic_Web_icon XML_icon};
    Cryptography_icon -> {Computers_icon Semantic_Web_icon};
    Dertouzos_icon -> {Berners_Lee_icon Computers_icon};
    Ontology_icon -> Semantic_Web_icon;
    Rejewski_icon -> {Cryptography_icon Turing_icon};
    Search_Engines_icon -> Semantic_Web_icon;
    Semantic_Web_icon -> {Agents_icon Computers_icon};
    Small_World_icon -> {Agents_icon Biology_icon Chaos_icon};
    Social_Networks_icon -> {Biology_icon Small_World_icon};
    Turing_icon -> {Automata_icon Computers_icon Cryptography_icon};
    XML_icon -> {Computers_icon Semantic_Web_icon};

    fontsize=28;
    label="From Past to Future...";
}

And that's what it looks like:

graphviz output

Second variant, with rank=same subgraphs uncommented:

graphviz output

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • 12 _Custom Models and Training with TensorFlow_2_progress_status_bar_Training Loops_concrete
    12 _Custom Models and Training with TensorFlow_tensor_ structure_Activation_Layers_huber_Loss_Metrichttps://mp.csdn.net/console/editor/html/107294292 Computing Gradients Using Autodiff To understand how to use autodiff (see https://blog.csdn.net/Linli522362242/article/details/106849041 and https://blog.csdn.net/Linli522362242/article/details/106290394) to compute gradients automatically, let’s consider a simple toy function: def f(w1, w2): return 3*w1**2 + 2*w1*w2 If you know calculus, you can analytically find that the partial derivative of this function with regard to w1 is 6 * w1 + 2 * w2
  • 如何在另一个文件中包含YAML文件?(How can I include a YAML file inside another?)
    问题 因此,我有两个YAML文件“ A”和“ B”,我希望将A的内容插入B内,或者拼接到现有的数据结构(如数组)中,或者作为元素的子级(如值)对于特定的哈希键。 这有可能吗? 如何? 如果不是,是否有任何指向规范性引用的指针? 回答1 不,YAML不包含任何类型的“导入”或“包含”语句。 回答2 您的问题并不要求提供Python解决方案,但这是一个使用PyYAML的解决方案。 PyYAML允许您将自定义构造函数(例如!include )附加到YAML加载程序。 我提供了可以设置的根目录,以便该解决方案支持相对和绝对文件引用。 基于类的解决方案 这是一个基于类的解决方案,它避免了原始响应的全局根变量。 有关类似的,更强大的Python 3解决方案,请参见此要点,该解决方案使用元类注册自定义构造函数。 import yaml import os class Loader(yaml.SafeLoader): def __init__(self, stream): self._root = os.path.split(stream.name)[0] super(Loader, self).__init__(stream) def include(self, node): filename = os.path.join(self._root, self.construct_scalar
  • 通过用于Java的PREFUSE库显示节点时出现问题?(Problem in displaying nodes through PREFUSE library for Java?)
    问题 我正在使用PREFUSE库开发数据的图形视图。 我的图中有3种节点: 应用数据库界面 以下是我的包含图表的.xml文件的摘录 <node id="AP-1"> <data key="name">Application1</data> <data key="type">APPLICATION</data> </node> <node id="DB-1"> <data key="name">Database1</data> <data key="type">DATABASE</data> </node> <node id="IT-1"> <data key="name">Interface1</data> <data key="type">INTERFACE</data> </node> 我想显示以上3个差异。 具有3个差异的各种节点。 各种形状如下: 矩形的应用 DATABASE按自定义形状(圆柱形状,通常用于表示数据库) 圈出界面 我首先阅读了.xml文件, 图g Q1。 现在如何区分数据组中的这三种节点。 我认为我应该写谓词。 我已经阅读了完整的谓词和表达式手册,以了解它们的用法,但无法编写谓词来区分它们。 那么,谓词是什么? Q2。 如何指定我的自定义形状以及如何设置可以渲染我开发的自定义形状的渲染器? 回答1
  • YOLO v3:DarkNet框架 转 OpenVINO框架
    目录 转换流程Darknet model -> TensorFlow modelTensorFlow model -> IR model修改配置文件转换 测试 转换流程 Darknet model tensorflow-yolo-v3 TensorFlow model OpenVINO IR model Darknet model -> TensorFlow model Darknet yolo模型包含两个文件:.cfg、.weights。其中cfg保存有模型的结构,weights保存有模型的参数。 TensorFlow yolo模型格式为.pb,其中包含所有推理所需的模型结构与参数。 tensorflow-yolo-v3中包含有转换代码,但是readme上显示仅支持到TensorFlow 1.11.0,估计2.0 +不行,况且OpenVINO也不支持2.0 +。 由于本机已经安装TensorFlow 2.1.0,故需要使用虚拟环境 创建虚拟环境 >>> git clone https://github.com/mystic123/tensorflow-yolo-v3.git >>> cd tensorflow-yolo-v3 >>> mkdir env >>> python3 -m venv env The virtual environment was not created
  • Using bullets list in tikz's node label in rmarkdown
    I have a tikz code to generate some graphs that works properly in latex (tested on overleaf: https://www.overleaf.com). However, this is supposed to be part of a large rmarkdown file but I cannot seem to use bullets list in some of my node labels while in rmarkdown. My questions are: how can I use a list of bullets as tikz's node label in rmarkdown? how can I customize that list to include some formatting like color, margin etc.? Where do things defined in latex using \newlist, \setlist go when using rmarkdown? I could generate these figures in latex and include them using knitr::include
  • 给定张量流模型图,如何查找输入节点和输出节点名称(Given a tensor flow model graph, how to find the input node and output node names)
    问题 我在Tensor Flow Camera Demo中使用自定义模型进行分类。 我生成了一个.pb文件(序列化的protobuf文件),并且可以显示其中包含的巨大图形。 要将此图转换为优化的图(如[https://www.oreilly.com/learning/tensorflow-on-android]中所述),可以使用以下过程: $ bazel-bin/tensorflow/python/tools/optimize_for_inference \ --input=tf_files/retrained_graph.pb \ --output=tensorflow/examples/android/assets/retrained_graph.pb --input_names=Mul \ --output_names=final_result 在这里,如何从图形显示中找到input_names和output_names。 当我不使用专有名称时,设备崩溃: E/TensorFlowInferenceInterface(16821): Failed to run TensorFlow inference with inputs:[AvgPool], outputs:[predictions] E/AndroidRuntime(16821): FATAL EXCEPTION
  • Shader Graph Example Library 案例
    Shader Graph Example Library下载地址:https://download.csdn.net/download/qq_17523181/12228933 本案例使用Unity2019.3测试,做过一些改动。 原版官方下载地址:https://github.com/UnityTechnologies/ShaderGraph_ExampleLibrary Procedural ShaderGraph平面应用 1. Shape Ellipse 效果显示 Shader Graph 节点说明: 【Unlit Master】 说明:不受光照的主节点,通过Shader->Unlit Graph创建 【Ellipse】 说明:椭圆形状 【Multiply】 说明:乘节点,A乘以输入B。如果这两种输入都是向量类型,则输出类型将是与这些输入的计算类型相同的向量类型。 整体说明: 通过Ellipse出来形状,和Unlit Master结合,中间用颜色(Multiply) 结合 所有形状在Procedural->Shapes造型下面所有形状(Ellipse、Polygon、Rectangle、Rounded Rectangle) 2. Shape Ellipse 效果显示 Shader Graph 节点说明: 【Split】 说明:分割输入向量在……里面变成四矢量1产出R, G
  • 有什么有效的数据结构和算法可以模拟加载的骰子?(What are efficient data structures and algorithms for simulating loaded dice?)
    问题 假设我有一个n边加载的骰子,当我掷骰子时,每边k都有几率p k出现。 我很好奇是否有一个好的数据结构来静态存储此信息(即,针对一组固定的概率),以便我可以有效地模拟骰子的随机掷骰。 目前,我有一个O(lg n )解决此问题的方法。 这个想法是存储所有k的前k个边的累积概率表,然后生成一个在[0,1)范围内的随机实数,然后对该表执行二进制搜索以获取其累加值最大的索引不大于所选值。 我更喜欢这种解决方案,但是运行时没有考虑到这些可能性似乎很奇怪。 特别地,在极端情况下,总是出现一侧或值均匀分布的情况,有可能使用幼稚的方法生成O(1)的滚动结果,而我的解决方案仍将采用对数的许多步骤。 是否有人对运行时以某种“自适应”方式解决此问题有任何建议? 更新:根据对这个问题的回答,我写了一篇文章,描述了解决该问题的许多方法以及它们的分析。 看起来Vose对别名方法的实现为每个模具辊提供了Θ( n )预处理时间和O(1)时间,这确实给人留下了深刻的印象。 希望这是对答案中包含的信息的有用补充! 回答1 您正在寻找一种别名方法,该方法提供一种O(1)方法来生成固定的离散概率分布(假设您可以在固定时间内访问长度为n的数组中的条目),并且设置为一次O(n)。 。 您可以在Luc Devroye撰写的“非均匀随机变量生成”的第3章(PDF)中找到该文档。 这个想法是采用概率数组p
  • 是否可以在d3.js中导入svg形状?(Is it possible to import svg shapes in d3.js?)
    问题 d3.js的第一天进展顺利,但我需要将占位符的圆形更改为更复杂的东西。 我在Illustrator中创建的SVG形状能否“导入”到d3.js图表​​中? 我知道我可以在d3中重绘它...但是我的头现在很疼...呃... 这是一个简单的泡泡,但有一点: <?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="77px" height="41px" viewBox="0 0 77 41" enable-background="new 0 0 77 41" xml:space="preserve"> <path
  • 带Dot / GraphViz的族谱布局(Family tree layout with Dot/GraphViz)
    问题 我正在尝试使用Dot和GraphViz绘制家谱。 这是我目前拥有的: # just graph set-up digraph simpsons { ratio = "auto" mincross = 2.0 # draw some nodes "Abraham" [shape=box, regular=1, color="blue"] ; "Mona" [shape=box, regular=1, color="pink"] ; "Clancy" [shape=box, regular=1, color="blue"] ; "Jackeline" [shape=box, regular=1, color="pink"] ; "Herb" [shape=box, regular=1, color="blue"] ; "Homer" [shape=box, regular=1, color="blue"] ; "Marge" [shape=box, regular=1, color="pink"] ; "Patty" [shape=box, regular=1, color="pink"] ; "Selma" [shape=box, regular=1, color="pink"] ; "Bart" [shape=box, regular=1, color="blue"] ;
  • PyTorch张量的概念以及创建方法
    PyTorch张量 文章目录 PyTorch张量前言一、Tensor与Variable二、创建张量的三种方法1.直接创建2.依据数值创建3.依据概率分布创建张量 前言 张量是一个多维数组,它是标量,向量,矩阵的高维拓展。 一、Tensor与Variable Variable是torch.autograd中的数据类型,主要用于封装Tensor,进行自动求导。 在pytorch0.4.0版本之后,Variable已经并入了Tensor,不再需要这个数据类型。但功能差不多。 torch.autograd.variable中有: data:被封装的Tensor grad:data的梯度 grad_fn:创建Tensor的function,是自动求导的关键 requires_grad:指示是否需要计算梯度 is_leaf:指示是否为叶子结点(张量) 共五个属性 0.4.0版本开始,Variable并入Tensor torch.Tensor中有: data:被封装的Tensor grad:data的梯度 grad_fn:创建Tensor的function,是自动求导的关键 requires_grad:指示是否需要计算梯度 is_leaf:指示是否为叶子结点(张量) 新增属性: dtype:Tensor的数据类型(32-bit float,64-bit int等) shape:Tensor的形状
  • Keras Kernel Initialization with numpy array unable to use load_model
    I am trying to use a numpy array from a pretrained model, to initialize a kernel in my keras model. Therefore I am writing my own Initializer function. The function is embedded in a callable class to avoid issues when using load_model. It seems that passing an array as a parameter to the initializer does not work in my case. My current solution is inspired by: keras kernel initializers are called incorrectly when using load_model Where the answer provided works fine for me in the case of passing a single number parameter to the initializer function. Upon using an array the error occurs. I have
  • 【转载】使用python库--Graphviz为论文画出漂亮的示意图
    1 LicenseCopyright (C) 2013, 2014, 2015, 2016, 2017, 2018 Tony Ballantyne. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.Code in this document is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version
  • Problem in displaying nodes through PREFUSE library for Java?
    I am developing a graphical view of data using PREFUSE library. I have 3 kinds of nodes in my graph: APPLICATION DATABASE INTERFACE Below are some excerpts from my .xml file containing graph <node id="AP-1"> <data key="name">Application1</data> <data key="type">APPLICATION</data> </node> <node id="DB-1"> <data key="name">Database1</data> <data key="type">DATABASE</data> </node> <node id="IT-1"> <data key="name">Interface1</data> <data key="type">INTERFACE</data> </node> I want to show the above 3 diff. kinds of nodes with 3 diff. kinds of shapes as follows: APPLICATION by Rectangle DATABASE by
  • TensorRT介绍、安装和测试
    1. What is TensorRT ? TensorRT的核心是一个C++库,能在NVIDIA的图像处理单元(GPU)上进行高性能的推断。它为与TensorFlow, Caffe, PyTorch, MXNet等主流训练框架进行互补工作而设计,专注于在GPU上高效地运行训练好的网络,生成预测结果。 有些训练框架,如TensorFlow,已经集成了TensorRT,所以能够直接在框架内部加速推断。除此之外,TensorRT可以用作应用程序中的库。它包含了一些用于导入TensorFlow, Caffe, PyTorch, MXNet等不同框架模型的解析器,提供了C++和Python 的API来构建模型。     TensorRT通过组合层和优化内核选择来优化网络,从而能改善延迟、吞吐量、功效和内存消耗,如果需要的化,可以以较低精度的方式运行来进一步提升模型运算的性能。   TensorRT被定义为高性能推理优化器和部件运行引擎的一部分,它接受在一些主流框架上训练的模型,优化神经网络计算,生成轻量级运行引擎。 1.1 Benefits Of TensorRT 主要在以下几个方面:   吞吐量: 通过 推理量/每秒 或 样本量/每秒 来衡量;   效率:单位功率的吞吐量,通常表示为性能/瓦特   延迟:执行推理需要的时间,通常是毫秒级   准确率:训练的模型提供准确答案的能力
  • 如何使用Java中的桥接技术实现协变方法重写(How covariant method overriding is implemented using bridging Technique in java)
    问题 在阅读协变量替代时,我发现了一个非常奇怪的事实, 使用桥接技术实现协方差方法覆盖。 它还说此功能是在java5及更高版本中实现的。(我认为这是因为从java5引入了泛型) 怎么发生的。请帮我举个例子。 回答1 考虑一个例子: public interface Shape<T extends Shape<T>> { T getType(); void setType(T type); } public class Circle implements Shape<Circle> { Circle getType() { } void setType(Circle circle) { } } 到目前为止看起来不错。 但是,在擦除类型之后,接口松开了它的泛型类型,并用上限替换了类型T 因此,接口和类如下所示: public interface Shape { Shape getType(); void setType(Shape type); } public class Circle implements Shape { Circle getType() { } void setType(Circle circle) { } } 现在,这就是问题所在。 擦除后在Circle使用的方法实际上不是Shape的重写版本。 请注意,现在的方法看上去对所采用的参数和返回的值施加了更大的限制。
  • 如何给JointJS元素一个删除工具?(How to give JointJS elements a remove tool?)
    问题 在JointJS中,链接带有一个方便的响应工具,用于删除链接(当您将鼠标悬停在链接上时,会出现一个“ x”,然后单击它会删除该链接)。 另一方面,元素在API中具有remove()方法,但没有UI“ x”向用户公开该方法。 有没有一种直接的方法可以使用户删除UI中的元素? 回答1 在我的项目中,我定义了一个自定义形状toolElement封装了此行为,然后根据需要将其扩展为其他自定义形状。 全面披露:该技术在很大程度上依赖于用于链接的jointjs代码-我刚刚对其进行了改编:o) 这是一个显示其工作原理的jsfiddle: http://jsfiddle.net/kj4bqczd/3/ toolElement的定义如下: joint.shapes.tm.toolElement = joint.shapes.basic.Generic.extend({ toolMarkup: ['<g class="element-tools">', '<g class="element-tool-remove"><circle fill="red" r="11"/>', '<path transform="scale(.8) translate(-16, -16)" d="M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16
  • 通过拖入javafx 2来移动节点的正确方法?(correct way to move a node by dragging in javafx 2?)
    问题 我正在将具有很多自定义绘画功能的Swing / Graphics2D应用程序转换为JavaFX2应用程序。 尽管我绝对喜欢新的API,但是在绘制椭圆时我似乎遇到了性能问题,无论鼠标移动到哪里,我都想在鼠标光标下方绘制一个椭圆。 当我稳定地移动鼠标而不是快得不可思议时,我注意到椭圆总是在鼠标轨迹后方几厘米处画出,并且只有在停止移动光标时才会赶上椭圆。 这在只有几个节点的场景图中。 在我的Swing应用程序中,我没有这个问题。 我想知道这是绘制鼠标光标所在形状的正确方法吗? import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.SceneBuilder; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Ellipse; import javafx.scene.shape.EllipseBuilder; import javafx.stage.Stage; public class
  • 使用 png 或 svg 图像作为 graphviz 节点(Using png or svg image as graphviz node)
    问题 我尝试在 graphviz 中使用自定义图像节点(节点d ): digraph foo { rankdir=LR; node [shape=record]; a [label="{ <data> 12 | <ref> }", width=1.2] b [label="{ <data> 99 | <ref> }"]; c [label="{ <data> 37 | <ref> }"]; d [image="X_Shape_Pillar_Yellow.png"]; a:ref:c -> b:data [arrowhead=vee, arrowtail=dot, dir=both, tailclip=false, arrowsize=1.2]; b:ref:c -> c:data [arrowhead=vee, arrowtail=dot, dir=both, tailclip=false]; c:ref:c -> d [arrowhead=vee, arrowtail=dot, dir=both, tailclip=false]; } 不幸的是,图像没有出现: 我已经使用以下方法编译了点文件: dot -v -Tpng list.dot -o list.png 我的代码(包括 png 图像)存储在 github 中。 如何将替换节点d与我的自定义图像一起使用? 回答1
  • 在 QML 中绘制虚线和虚线贝塞尔曲线(Draw a dashed and dotted bezier curve in QML)
    问题 我已经看到 QML 中有一个贝塞尔曲线的示例实现,但我正在寻找如何实现虚线或虚线贝塞尔曲线的提示。 据我所知,贝塞尔曲线示例的作者正在使用QSGGeometryNode存储在QSGGeometry并在其上应用QSGFlatColorMaterial材料。 然后他们简单地创建点列表并在它们之间绘制线段。 是否可以编写一个shader并将其应用于QSGFlatColorMaterial (以将线显示为dashed 、 dotted等)? 最终,是有可能不止一个存储QSGGeometry内QSGGeometryNode ? 更新 我想在“纯QtQuick ”中实现这一点——而不是在“旧”接口(如QPainter etc )中——因为我不想使用切换上下文(openGL 和 CPU)的东西。 我更喜欢使用自定义着色器的解决方案(如果它可行) - 因为我将有更多的可能性来实现自定义外观(虚线、虚线、彩色、可能是动画等)。 如果不可能,我将使用QPainter 。 回答1 我不认为这个任务是使用QSGGeometryNode实现的好QSGGeometryNode ,使用基于QPainter的绘图和QQuickPaintedItem来实现它会容易QQuickPaintedItem 。 你仍然会得到 OpenGL 的好处,因为QPainter支持 GL 绘图,而且它仍然比软件更快。