Comments (12)
thanks.
I changed the the GCN model return F.sigmoid(x)
and replace the loss function F.nll_loss using loss_train = F.binary_cross_entropy(output[idx_train], labels[idx_train]). is my change correct?
from pygcn.
from pygcn.
from pygcn.
hello, have you finish the multi-label problem?
from pygcn.
I need to use GCN with TensorFlow, have you try multi-label problem with Tensorflow?
The changes I make as follow:
loss = tf.nn.sigmoid_cross_entropy_with_logits(logits=preds, labels=labels) (from metrics.py)
correct_prediction = tf.equal(preds, labels). (from metrics.py)
return tf.nn.sigmoid(self.outputs). (from models.py)
So is it correct?
from pygcn.
@Chengmeng94 It seems to be correct. Make sure to adapt the accuracy function as well to handle a sigmoid output instead of a softmax output. currently it is just taking the max, as you would expect for a softmax function, so it is just evaluating a single label. This is typically done with some threshold.
from pygcn.
@anjanaskumar27 My response was to a mult-label situation, rather than a multi-class situation. I think the original code already works for multi-class situations.
from pygcn.
@Baukebrenninkmeijer sorry, my bad. I meant to ask procedure for multi label. The following are my changes:
loss = tf.nn.sigmoid_cross_entropy_with_logits(logits=preds, labels=labels) and correct_prediction = tf.equal(preds, labels) in metrics.py .
And use tf.nn.sigmoid(self.outputs) to predict in models.py.
As suggested in tkipf/gcn#119
Can you tell me what is wrong here? Or what needs to be updated in accuracy?
from pygcn.
@anjanaskumar27 As far as I can see here, this should be correct except maybe for the metric. I'm not an expert on metrics for multilabel, but I expect just accuracy (which is what you get with the tf.equal) is not the most appropriate, although it still gives you some indication.
from pygcn.
@Chengmeng94 @tkipf @Baukebrenninkmeijer , to allow multi-label mulit-class classification:
In addition to @Chengmeng94 changes (as follows),
loss = tf.nn.sigmoid_cross_entropy_with_logits(logits=preds, labels=labels) in model.py
tf.nn.sigmoid(self.outputs) to predict in models.py
I added,
logits_prob = tf.nn.sigmoid(preds, name = 'log_prob')
predictions = tf.cast(logits_prob > 0.5, tf.float32,name='predictions')
correct_prediction = tf.equal(predictions,labels)
Is this correct?
from pygcn.
@anjanaskumar27 tensorflow is not my strongsuit, but a quick google advised the following. Use tf.round()
to push the prediction to either 0 or 1. Then you can calculate metrics. This appears to make sense. Let me know if it works out. Please report if correct_prediction is an NxL matrix, where N is the number of samples and L the number of labels.
So in short, i think you should do:
correct_prediction = tf.equal(tf.round(tf.nn.sigmoid(self.outputs)), labels)
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
from pygcn.
@Baukebrenninkmeijer , thank you for the suggestion. I am new to tensorflow as well, thus finding it little tricky to modify things.
For me, the size of correct predictions is 2x1. I may have to fix this?
Additionally, wrt to the code in utils.py, line #77, idx_val = range(len(y), len(y)+500), do you have any idea why they add 500 here? My graph with total nodes of 70, seems to fail because of this.
Thank you for the help!
from pygcn.
Related Issues (20)
- specifying modes train, validation and test HOT 1
- Where is Filter parameters in the code? HOT 1
- Hi, does pandas make the data preprocessing more simple?
- Normalization of features, batch-wise training, feature extraction
- question about the adjacency matrix HOT 2
- citeseer dataset seems doesnot work HOT 2
- Difference between TF and Pytorch version code HOT 5
- In tensor flow code you used early stopping,isn't it needed in pytorch???
- In `utils.py` line 36, wouldnt `adj = adj + (adj.T > adj)` also work? HOT 2
- Invoice node classification / meta-data extraction / single prediction with trained model
- How to do a semi-supervised learning? HOT 6
- Predicting node degree
- Question About fastmode
- Error: 'pybind11' must be installed before running the build.
- transform to other scope dataset
- Why do row normalization instead of column normalization? HOT 2
- About the dataset split HOT 3
- citeseer dataset
- Cora dataset attributes
- accuracy in the experimental results HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygcn.