alvinwan / neural-backed-decision-trees

Making decision trees competitive with neural networks on CIFAR10, CIFAR100, TinyImagenet200, Imagenet
https://nbdt.aaalv.in
MIT License
607 stars 130 forks source link

Getting the intermediate decisions on Colab #2

Closed WesDeng closed 3 years ago

WesDeng commented 4 years ago

When I call _model.forward_withdecisions to get the intermediate decisions on Colab, we get a list of 'node': <nbdt.data.custom.Node object at 0x7f2318a35a90> objects. How could I get access to the information within the node? And how could I generate a visualization of a decision tree based on this result?

alvinwan commented 4 years ago

Great questions. Thanks for using the repo!

1. How to get information in node?

I realized the Colab notebook by default uses the SoftNBDT. I suggest changing that to a HardNBDT instead, as forward_with_decisions for HardNBDT comes with more human-readable labels right off the bat.

You can also do this for SoftNBDT: Each node has an attached synset .synset, and you can get the node name from the synset synset_to_name.

2. How to generate visualization?

There are a number of example visualizations in the README, in 1. Hierarchies (including how to reproduce the figures in the paper).

Let me know if you have any further questions.