microsoft / tf-gnn-samples

TensorFlow implementations of Graph Neural Networks
MIT License
914 stars 229 forks source link

Some questions about graph classification. #9

Closed HuantWang closed 4 years ago

HuantWang commented 4 years ago

Sorry to bother you. I want to classify graphs (each graph has a label and contains multiple nodes). I have read the cases in your project. If I want to fulfill my needs, pm9 is a regression problem. I want to change it to a classification problem. ppi is the classification of the nodes, and I want to change to the classification of the graph. What is the fastest way to do it, and I hope to get your suggestions,thank u.

mmjb commented 4 years ago

The easiest way of doing this would be to take the QM9 task as basis, and then use a tf.nn.sigmoid on the final output per graph, e.g., in https://github.com/microsoft/tf-gnn-samples/blob/master/tasks/qm9_task.py#L188. That would ensure that the resulting value is in [0,1].

In the updated TF2 implementation, https://github.com/microsoft/tf2-gnn/blob/master/tf2_gnn/models/graph_binary_classification_task.py implements this explicitly.