Is there a way to extract geometric information out of cad model for feature recognition? - pytorch

I am really new to this so any help is appreciated so basically I am trying to use PyTorch geometric to identify topological features within 3D CAD models (i.e. slots, pockets, holes, etc) but in order to do that I need to represent the cad model into a graph in PyTorch geometric.
For the input data, I am thinking of using adjacency of the faces to identify the features within the model.
Below is an example that is what I want to achieve out of a 3D model. The
relationships between each face are represented in a graph format.
So after getting the above graph I want to feed that to the algorithm for the graph classification.
The issue that I am facing is how can I extract that adjacency information out of the CAD model (i.e. Let's say face 1 is connected to face 3 so I take the 2 faces as two nodes in the graph and connect the two-node with an edge as both faces are touching each other) makes a graph out of it as shown in the above image.
I did come across one tool called pythonOCC not sure I can use that to extract the adjacency information out of it, if possible please suggest what I can do using that tool.

Related

How to batch a nested list of graphs in pytorch geometric

I am currently training a model which is a mix of graph neural networks and LSTM. However that means for each of my training sample, I need to pass in a list of graphs. The current batch class in torch_geometric supports batching with torch_geometric.data.Batch.from_data_list() but this only allows one graph for each data point. How else can I go about batching the graphs?
Use diagonal batching:
https://pytorch-geometric.readthedocs.io/en/latest/notes/batching.html
Simply, you will put all the graphs as subgraphs into one big graph. All the subgraphs will be isolated.
See the example from TUDataset:
https://colab.research.google.com/drive/1I8a0DfQ3fI7Njc62__mVXUlcAleUclnb?usp=sharing

Neural network graph visualization

I would like to generate visualization of my neural network (PyTorch or ONNX model) similar to this using Graphcore Poplar.
I have looked in the documentation but I cannot find where this visualization feature is.
How can I achieve such a task ? Is there any other existing library ?
that visualization is not part of the Graphcore Poplar software. It is "data art" generated by the team at GraphCore.
It is a tough work and requires many hours to get to that fine quality, but if you are decided, I would suggest to start looking at graph visualization tools looking for "graph network visualization" (and get inspiration from galleries like https://cytoscape.org/screenshots.html).
The NN architecture can be converted into a common graph format (neurons as nodes, connections as edges) and then you may start trying.
Some ideas:
Start with a simple NN with three layers. Place the input layer at the outer circle, there is a inner circle for the hidden layer and the output layer is placed in the center. Each neuron is a dot, with radius relative to the weight and color with the bias, and you can displace it towards/away the neurons in the previous layers based on the weight. Check this image for inspiration if you are looking for a "biological" style: https://cytoscape.org/images/screenshots/edge_bundling3_1400px.png

Using edge features for GCN in DGL

I'm trying to implement a graph convolutional network (GCN) in the Deep Graph Learning (DGL) package for Python. In many papers, edges have discrete features, and each possible value is associated with a different weight matrix or set of weight matrices. An example would be here. Is anyone familiar with how to implement a model like this in DGL? The DGL team's example of GCNs for graph classification, as does another example I found online.
Not sure whether the question still needs to be answered, but I guess it boils down to how to implement models like R-GCN or HGT with DGL. Some of these layers come build-in with DGL here. But it is also easy to implement your own computations. The following explanation only makes sense if you know the basic computational process of DGL during a forward pass through a graph layer (message, reduce, apply_node), if not DGL has good tutorials on that as well. To extend the usual graph computation to for example edges of different types you need to create a heterogenous Graph object and call multi_update_all on that graph object. You can pass a dictionary to that function which specifies the computation per edge type.

Is it possible to achieve something similar to word2vec using a graphdb?

Otherwise said replace eigen vectors with pattern matching and graph traversal and emulate dimension reduction?
I mean that given a semantic graph of english words compute something similar to:
king - man = queen
Which means that I can subtract from a graph a subgraph and score the resulting subgraph given a metric.
I don't expect that this will be a single neo4j or gremlin query. I'm interested in the underlying mechanic involved in reasoning at the same time globaly and localy over a graph database.
I think it's important to remember the difference between graph databases as a storage solution and then using machine learning to extract connected graphs as vectors that represent features that are used to train a ML model proper.
The difference is that you can structure your data in such a way that makes it easier to find patterns that are suitable for creating a machine learning model. It's certainly a good idea to use Neo4j to do this but it's not something that comes out of the box. I've created a plugin to Neo4j that will extract hierarchical pattern matches from text using a genetic algorithm that I thought up. You can take a look here: http://www.kennybastani.com/2014/08/using-graph-database-for-deep-learning-text-classification.html
You can then use the resulting data to construct a word2vec model.

dimension reduction makes data non-linearly separable

I am working on a project to classify hearing disorders using SVM. I have collected real time data from the site (http://archive.ics.uci.edu/ml/machine-learning-databases/audiology/) and initially decided to go for two classes to classify patients with normal ear and patients with any disorder. Varying the optimization parameter C from 0.1 to 10 I get one miss-classification between the two classes (C=10).
However I wan to plot the data with the decision boundary but the data set has around 68 features so it is not possible to plot it. I used PCA to reduce to 2D and used svm on this data to see the results. But when I use PCA, the data no longer remains linearly separable and linear decision boundary cannot separate the 2D PCA data. So I want to know if there is a way to reduce dimension but to retain the nature of the data (nature as in separability using linear decision boundary). Can anyone please help me?
Thanks

Resources