简体   繁体   English

TensorFlow - 使用 networkx 图作为输入

[英]TensorFlow - Using networkx graph as input

I am trying to use TensorFlow to build an artificial neural network which can identify features in a CAD model.我正在尝试使用 TensorFlow 构建一个人工神经网络,该网络可以识别 CAD 模型中的特征。

Using the CAD model data I have computed the adjacency between certain faces and plotted it on a graph where each node is a face, each edge between faces represents adjacency and weights of 0 and 1 represent a convex and concave relationship respectively.使用 CAD 模型数据,我计算了某些面之间的邻接并将其绘制在每个节点是一个面的图形上,面之间的每条边表示邻接,0 和 1 的权重分别表示凸凹关系。 Below is the code which draws the adjacency graph:下面是绘制邻接图的代码:

import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline

G=nx.Graph()

#adding nodes
G.add_nodes_from(range(1, 10))

#adding edges
G.add_weighted_edges_from([(1, 2, 0), (1, 3, 0), (1, 6, 1), (1, 8, 1),
(2, 5, 1), (2, 6, 1), (2, 8, 1), (3, 4, 1),(3, 6, 1), (3, 8, 1), 
(4, 6, 1), (4, 7, 1), (4, 8, 1), (5, 6, 1), (5, 8, 1), (5, 9, 1),
(6, 7, 1), (6, 9, 1), (6, 10, 1), (7, 8, 1), (7, 10, 1), (8, 9, 1), 
(8, 10, 1), (9, 10, 1)])

#draw AAG
nx.draw_circular(G, node_color = 'bisque', with_labels=True)

My question is: is it possible to feed the adjacency graphs into a neural network in TensorFlow, teaching it which faces make up the 'features' present in the model?我的问题是:是否可以将邻接图输入 TensorFlow 中的神经网络,教它哪些面孔构成模型中存在的“特征”?

Any help on the subject would be appreciated任何有关该主题的帮助将不胜感激

In principle you could, assuming you can present your graph as a list-like data structure.原则上您可以,假设您可以将您的图形显示为类似列表的数据结构。 But the question is, how are you going to train your network?但问题是,你将如何训练你的网络? First, you need to have thousands (and thousands) of samples of such graphs, so you can feed them in batches into your TF model.首先,您需要拥有数千个(和数千个)此类图的样本,以便您可以将它们分批输入到您的 TF 模型中。 Second, for each of the samples, you will need to make a clear distinction of what represents the features and what represents the label.其次,对于每个样本,您需要明确区分什么代表特征和什么代表标签。 You can't expect TF to figure out WHAT makes up the features, you will need to SPECIFY that.你不能指望 TF 弄清楚这些特性是什么组成的,你需要指定它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM