# requirements.txt is a flattened conda export, and the 10% gain is confounded

> A PyTorch reproduction of Deep Hierarchical Classification where the parent logits feed the child head. Two things to know before you use it: the dependencies file is a conda dump, and the reported advantage over a single ResNet-50 came with different data augmentation.

**Ugenteraan/Deep_Hierarchical_Classification** — PyTorch Implementation of Deep Hierarchical Classification for Category Prediction in E-commerce System

- Repository: https://github.com/Ugenteraan/Deep_Hierarchical_Classification
- Stars: 99 · Forks: 22
- Language: Python
- License: MIT
- Published: 2026-08-17 · Updated: 2026-08-18 · Language: en
- Canonical page: https://hysenlabs.com/projects/ugenteraan-deep-hierarchical-classification

## requirements.txt is a conda export, not a pip file

This is the first thing anyone who tries to set the project up will hit, and it is worth describing exactly rather than summarising.

`requirements.txt` begins with the header line `# Name Version Build Channel` and then lists packages as whitespace-separated tokens with their version, their build string and their channel. So a line reads like `ca-certificates 2020.12.8 h06a4308_0 conda`, which is the output of a conda environment export flattened onto one line rather than the `package==version` lines pip expects.

The pins are also of their period. The visible entries carry `py36` build tags, which is the CPython 3.6 series, and package versions from 2020. The list also carries entries with no obvious connection to image classification: `gfootball`, `gym-super-mario-bros`, `ffmpeg`, `gstreamer`, `freeglut`, `dbus`, `brotlipy` and `jasper` are all in there.

Combined with the fact that the README contains no installation step at all, the practical position is this: `pip install -r requirements.txt` will not do what you want, and the environment has to be built by hand from what the training script actually imports, or by reconstructing a conda environment from the export.

## The superclass logits are concatenated into the subclass head

The architectural idea is one concatenation, and the page describes it in enough detail to be unambiguous.

The feature vector comes out of the backbone and goes two ways at once. One fully-connected stack ends in a layer whose neuron count equals the number of superclasses, producing a 20-D vector for CIFAR-100, and a softmax over it gives the superclass prediction. In parallel, another fully-connected stack ends in a layer sized to the number of subclasses, producing a 100-D vector.

Then the concatenation: that 100-D vector is joined with the previous level's prediction, specifically the 20-D vector before the softmax is applied, and one more fully-connected layer transforms the combination into a new 100-D vector. The page notes this step is not in the diagram and points at equation 4 of the original paper. A softmax over the final 100-D vector produces the subclass prediction.

Why it matters: the subclass decision is conditioned on what the model believes the superclass is, before that belief is rounded into a label. That is what lets a single model handle a hierarchy without the accuracy loss that one-model-per-level incurs, and it is the part of the architecture you would want to reimplement in your own framework.

## Two losses, and the consistency one is modified from the paper

The training objective has two parts, and the second is the one that makes the hierarchy mean anything.

The second loss type punishes the network when the prediction of the subclass does not belong to its superclass. Without it, a model can produce a confident subclass label that contradicts its own superclass label and lose nothing. With it, the two heads are pushed towards consistency.

This implementation modifies that particular loss function, and the page states that experiments showed the modification does not affect the performance at all. The code is pointed at, in `model/hierarchical_loss.py`.

Two things follow. First, that file is where the implementation differs from the paper, so it is the first place to look if your numbers do not match a published result. Second, the reassurance is a single sentence with no table behind it in the text available, so treat it as the author's report rather than as evidence.

The first loss type is not described on the page beyond being one of the two. Reading `train.py` is how you find out what it is and how the two are weighted.

## ResNet50 with CBAM on CIFAR-100's 20 superclasses and 100 subclasses

The experimental setup is stated in one paragraph and it is worth knowing exactly what was run, because the numbers on the page only mean anything against it.

The backbone is ResNet50 with CBAM. The dataset is CIFAR-100, described as 20 classes, called superclasses, each containing 5 subclasses, with 600 images per subclass split 500 for training and 100 for testing. That gives 100 subclasses and 20 superclasses, which is the arithmetic the two head sizes of 20 and 100 come from.

Three figures are reported, all over 100 epochs: the model loss, accuracy at the superclass level and accuracy at the subclass level.

The architecture diagram is not the author's own. Its caption credits the arXiv PDF as the image source, so the figure in the README is copied from the paper rather than drawn from the code. That is normal practice, and it is also why the text has to explain the concatenation step separately: the one operation that is not in the picture is the one the implementation adds.

The tree also holds `process_cifar100.py`, which is where the dataset is turned into the CSV and metafile format the training script expects.

## The 10% advantage came with different data augmentation

The conclusion section sets up the comparison carefully, and then the result undercuts itself in a way that is worth quoting rather than tidying up.

The framing: the older technique for a multi-level hierarchy was a separate model per level. That preserves accuracy because each level is predicted independently, but it is not cost-effective because you end up managing many models. So the question the implementation asks is whether DHC trades accuracy away to save that cost. To answer it, the author ran a second experiment using only ResNet-50 with CBAM on the CIFAR-100 subclass level.

The result, as stated: ResNet-50 with CBAM alone achieves almost the same accuracy as DHC, and DHC has about 10% more accuracy than ResNet-50 with CBAM. Then the explanation: this might be due to the use of slightly more aggressive data augmentation during training for DHC.

So the 10% is an upper bound on what the architecture contributes, because the two runs differ in augmentation as well as in head design. A comparison you would want to trust would hold augmentation fixed. Read the figure as evidence that the hierarchy costs nothing in accuracy, which is the claim actually being tested, rather than as evidence that it adds ten points.

## Using it on your own data means editing three files first

The How to Use section is a list of things to change, and it is the practical part of the page.

You need a `train.csv`, a `test.csv` and a metafile for your dataset, and the files in the `dataset/` folder are the reference for what those should look like. Then you modify the dictionary variable in `level_dict.py` to match your hierarchy, and modify `load_dataset.py` to load your data. If your dataset has more than two levels of hierarchy, you add the classifier layers in `models/resnet50.py`.

Training is one command:

```bash
python train.py --train_csv [PATH TO YOUR TRAIN CSV FILE] --test_csv [PATH TO YOUR TEST CSV FILE] --metafile [PATH TO YOUR METAFILE]
```

and `python train.py -h` prints the full argument list.

There is a path inconsistency worth hitting early. The page names `models/resnet50.py` for the classifier layers, plural models, while the tree has a single `model/` directory, which is also where `model/hierarchical_loss.py` lives. At least one of those paths is wrong, so look before you edit.

The rest of the top-level files map onto the steps above: `runtime_args.py` for the arguments, `helper.py` for utilities, `plot.py` for the figures, `level_dict.py` for the hierarchy and `load_dataset.py` for the data.

## Non-official, last pushed in 2022, and the paper is the reference

The framing sentence at the top of the page sets the expectations correctly: this is a non-official implementation of Deep Hierarchical Classification for Category Prediction in E-commerce System, with the paper linked as arXiv 2005.06692.

That matters for what you use it for. The paper is the specification; this repository is a runnable copy of one reading of it, with the differences it chose to make visible (the modified consistency loss) and the ones it did not spelled out in prose (the concatenation detail, deferred to equation 4). Anyone writing this from scratch should read the paper first and treat the code as a worked example.

The maintenance picture matches the framing. The last push to the `main` branch was on 2022-01-14, the repository publishes no releases, and it is not archived. There is no tests directory, no `.github/` directory and no continuous integration. Licence is MIT.

What is genuinely reusable is the structure, and it is laid out cleanly: separate modules for the hierarchy dictionary, the loader, the argument parser, the model and the loss, plus a `dataset/` folder holding the example inputs. Someone building hierarchical classification in PyTorch for an e-commerce category tree can lift the head design and the consistency loss from here and skip the packaging entirely.

## Conclusion

This implementation fits someone reproducing Deep Hierarchical Classification on a two-level image hierarchy who is prepared to read the training script and build the environment themselves, because the parent logits feeding the child head is the part worth seeing in code. It does not fit anyone wanting an installed package, a tested one, or an isolated accuracy number. Verify four things before you trust any result from it: that your hierarchy dictionary is set in `level_dict.py` and your loader adapted, that the classifier layer count matches your depth given the page points at `models/resnet50.py` while the tree holds `model/`, that you compare against a baseline trained with the same augmentation rather than the one in the figures, and that the modified hierarchical loss in `model/hierarchical_loss.py` matches what the paper describes. Licence is MIT, the paper is arXiv 2005.06692, and the last push was on 2022-01-14.

## FAQ

### What backbone does this Deep Hierarchical Classification implementation use?

ResNet50 with CBAM. The feature vector from that backbone feeds both heads, with the superclass head sized to the number of superclasses and the subclass head to the number of subclasses, which is 20 and 100 for CIFAR-100.

### How do I train the model on my own dataset?

Provide train.csv, test.csv and a metafile, set the hierarchy dictionary in level_dict.py, adapt load_dataset.py, and add classifier layers if the hierarchy goes beyond two levels. Then run train.py with --train_csv, --test_csv and --metafile; python train.py -h prints the arguments.

### How do I install the dependencies for Deep_Hierarchical_Classification?

The page gives no installation step, and requirements.txt is a flattened conda environment export with a Name, Version, Build and Channel header rather than pip-style requirement lines. Build the environment from the imports in the training script instead.

### Is Deep_Hierarchical_Classification an official implementation?

No. It states that it is a non-official implementation of Deep Hierarchical Classification for Category Prediction in E-commerce System, arXiv 2005.06692, and the architecture diagram in the README is credited to that paper.

### Is Deep_Hierarchical_Classification still being worked on?

The last push to the main branch was on 2022-01-14 and no releases are published. The repository is not archived, has no tests directory and no CI configuration, and the licence is MIT.

## Sources

- [Official README](https://github.com/Ugenteraan/Deep_Hierarchical_Classification#readme)
- [Project repository](https://github.com/Ugenteraan/Deep_Hierarchical_Classification)
- [README](https://github.com/Ugenteraan/Deep_Hierarchical_Classification/blob/main/README.md)
- [Releases](https://github.com/Ugenteraan/Deep_Hierarchical_Classification/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/ugenteraan-deep-hierarchical-classification
