Code Monkey home page Code Monkey logo

Comments (3)

tkipf avatar tkipf commented on September 4, 2024

Thanks for your question. Note that the evaluate_preds function takes an additional index/mask array, e.g. idx_train which is not the case in your keras-based implementation. This explains the difference in measured accuracy.

from keras-gcn.

dawnranger avatar dawnranger commented on September 4, 2024

Sorry for late response. I think I solved this issue. I mistakenly thought that the argument sample_weight is enough to apply weight to the input data. In fact we also need to use weighted_metrics but not metrics. I found that evaluate_pred can be replaced by mode.evaluate therefore we don't need to implement metrics categorical_crossentropy and accuracy. The codes can be simplified to keras-based implementation without changing the results. Here are my solutions:

  1. add weighted_metrics categorical_crossentropy and accuracy to model.compile:
model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=0.01), weighted_metrics=['categorical_crossentropy', 'accuracy'])
  1. evaluate the train data using mode.evaluate:
_, train_loss, train_acc = model.evaluate(
        graph, y_train, sample_weight=train_mask, batch_size=X.shape[0], verbose=0)

To be more simplified, we can also get rid of loops over epochs and use earlystopping callbacks.

from keras-gcn.

tkipf avatar tkipf commented on September 4, 2024

This sounds good, thanks for looking into this! Feel free to make a pull request if you think this might be helpful for other users as well.

from keras-gcn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.